thinkphp Common
In the common.php wrote a method, in the template call always error, run The Times wrong said is the template corresponding to the cache file introduced in Common.php method which line error, the entire page is messy, like no CSS introduced
file, but the cache file in the runtime folder has no red error, and part of the code that calls the methods in the common file is interpreted.
This is the code in commom/common.php.
Header ("Content-type:text/html;charset=utf-8");
function sub ($STR) {
$length =mb_strlen ($str, "utf-8");
if ($length >20) {
$str =mb_substr ($str, 0,20, "Utf-8"). " ...";
}
return $str;
}
function Cpy_name ($id) {
$model =m (' Cpy_info ');
$result = $model->where ("cpy_id= ' {$id} '")->find ();
return $result [' Cpy_name '];
}
?>
Here is the line of code in the template file that went wrong
{$v. cpy_id|sub} message to {$v. Accept|cpy_name}:
{$v. Content}
Or
{$v. cpy_id|sub=###} message to {$v. accept|cpy_name=##}:
{$v. Content}
The following is the corresponding cache file code
$V): + + $i; $mod = ($i% 2)?>
Right Message:
is not to call the method in the common also change what configuration??
thinkphp version is not a problem, can be called before ... , and now suddenly I can't find a problem ...
The rookie is asking for advice ................
Reply to discussion (solution)
Common.php is generally used to make a custom function library, can not output anything