Methods in calling public file common.php in thinkphp

Source: Internet
Author: User
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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.