ThinkPHP函数与类库调用方法
本示例演示了如何在ThinkPHP框架中调用函数与类库,供读者参考学习。
官方手册内容较为繁杂,此处简化说明具体用法。
函数调用:
全局公共函数库文件为 common.php
App/common/common.php
分组模块下的公共函数库文件为 function.php
App/Modules/Admin/common/function.php
类库调用:
class IndexAction extends Action{
public function index(){
// 调用“扩展基类库” ThinkPHP/Extend/Library/ORG/Util/Test.class.php
import('ORG.Util.Test');
$test = new Test();
// 调用“扩展基类库” ThinkPHP/Extend/Library/Com/Util/Test.class.php
import('Com.Util.Test');
$test = new Test();
// 调用“核心基类库” ThinkPHP/Lib/Core/Test.class.php
import('Think.Core.Test');
$test = new Test();
$this->display();
}
}
希望上述内容对基于ThinkPHP的PHP开发有所帮助。