Home  >  Article  >  Backend Development  >  ThinkPHP sample code for simply calling functions and class library methods

ThinkPHP sample code for simply calling functions and class library methods

黄舟
黄舟Original
2017-03-24 17:47:402080browse

This article mainly introduces how thinkPHP simply calls function and class library. It briefly describes the file location of thinkPHP's public function library and analyzes the calling of the class library with examples. Methods, friends in need can refer to

This article describes the method of calling functions and class libraries in thinkPHP. I would like to share it with you for your reference. The details are as follows:

The manual is very redundant and I don’t understand it. Let’s briefly explain the specific usage.

Function call:

lib public function library is called common.php

App/common/common. php

The public function library under the group module is called function.php

App/Modules/Admin/common/function.php

Class library call:

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();
  }
}

Related articles:

About thinkphp How to write your own functions and classes, where to put them, how to call them, please give me some advice

ThinkPHP3.2 framework uses addAll() to batch insert data. Share

thinkPHP database addition, deletion, modification and query operation method detailed explanation

The above is the detailed content of ThinkPHP sample code for simply calling functions and class library methods. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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