Home > php教程 > php手册 > thinkphp 自定义函数及使用方法

thinkphp 自定义函数及使用方法

WBOY
Release: 2016-06-01 09:46:50
Original
1096 people have browsed it

实例:

 

第一步:将自定义函数放在项目应用目录/common/common.php 或/common/function.php中。

<code class="language-php">function Cate($cid){ 
   $Cate=D('Cate'); 
   $Cate=$Cate->where('id='.$cid)->find(); 
   return $Cate['title']; 
} </code>
Copy after login

 

第二步:在模板中按照以下方法使用。

<code class="language-php">{$vo.cid|cate=###} </code>
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template