服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|JavaScript|易语言|

服务器之家 - 编程语言 - PHP教程 - thinkPHP简单调用函数与类库的方法

thinkPHP简单调用函数与类库的方法

2021-04-30 16:24chinalorin PHP教程

这篇文章主要介绍了thinkPHP简单调用函数与类库的方法,简单讲述了thinkPHP公共函数库的文件位置并结合实例分析了类库的调用方法,需要的朋友可以参考下

本文实例讲述了thinkPHP调用函数与类库的方法。分享给大家供大家参考,具体如下:

手册上说的很冗余,没看懂,下面简单的讲一下具体用法。

函数调用:

lib公共函数库叫 common.php

App/common/common.php

分组模块下的公共函数库叫 function.php

App/Modules/Admin/common/function.php

类库调用:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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程序设计有所帮助。

延伸 · 阅读

精彩推荐