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

ThinkPHP sample code for simply calling functions and class library methods

黄舟
Release: 2023-03-06 17:14:01
Original
2158 people have browsed it

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

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!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template