Smarty之方法插件

自定义方法

要放在plugins文件中,并且文件名必须按照smary的成品方法名格式来定义,一般是function.自定义名称.php.

例子:

<?php
function smarty_function_sub_change($args)
{
    $code = $args['code'];
    $db = new MySQLi("localhost","root","","mydb");
    $sql = "select name from subject where code = '{$code}'";
    $result = $db->query($sql);
    $arr = $result->fetch_row();
    return $arr[0];
}

 

posted @ 2016-06-05 21:54  天照丶鼬  阅读(154)  评论(0)    收藏  举报