


ThinkPHP calls common/common.php function prompts error function undefined solution, thinkphpcommon.php_PHP tutorial
ThinkPHP calls the common/common.php function and prompts the error function undefined solution, thinkphpcommon.php
This article mainly introduces the solution to the error function undefined when ThinkPHP calls the common/common.php function. For friends who use ThinkPHP for project development, they often encounter such problems after upgrading ThinkPHP. The specific description is as follows:
After upgrading ThinkPHP, I used the latest ThinkPHP 3.2 version and put the common functions in common/common.php. However, when calling the function on a specific page, an error message of function undefined appeared.
After checking the official documents, I found that it turns out that the ThinkPHP3.2 version common.php file has been renamed function.php,
So replaced common.php---> with function.php, and the function call was successful! Problem solved!
I hope the method described in this article will be helpful to everyone in ThinkPHP development.
1. How to name and use the public methods of the common folder in the thinkphp project:
Create a common.php file under the common folder (this is fixed)
->
common. You can customize functions in php files, such as: function aa($str){...}, the function name is arbitrary, and the parameters are arbitrary
->
Regarding how to use it, it is divided into two places, one is the controller (i.e. Action, such as loginAction.class.php), you can directly call the function, such as aa($title); the other is in the template file, which needs to be separated by "|", such as {$title|aa}
->
The most important point is that every time you change the common.php file, you need to delete the ~app.php file under the Temp folder, because common.php is first parsed into the ~app.php file, and then be called again.
2. This is simple, such as class IndexAction extends LoginAction{...}. Note: I usually capitalize the first letter of Action naming. I don’t know if it will work in lowercase. It is recommended to capitalize. The corresponding Model name should also be capitalized. Be more standardized.
common/common.php Just write it directly in this file in the method! You can write your own method! But you need to call the file you wrote when using your method! Also, thinkphp is a single-module entry. Just find their files and reference your files in them! This way you can use it directly in the future! ! ! !

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In daily office and study, printers are indispensable tools. However, encountering printer errors is a very common situation. Recently, some users have encountered error code 0x0000709 when using the printer, and the system prompts that the operation cannot be completed. We have prepared four solutions to this problem, let’s take a look. Method 1: NT6 Printer Sharing Repair Tool The NT6 Printer Sharing Repair Tool is an excellent printer repair tool that can easily solve the problem of printer sharing link failure caused by updating patches, such as the recent problem when connecting Win10 and Win11 to share a printer. Errors reported, printer error codes 0x0000011b, 0x00000709 and other issues. This tool provides

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP is a high-performance PHP framework with advantages such as caching mechanism, code optimization, parallel processing and database optimization. Official performance tests show that it can handle more than 10,000 requests per second and is widely used in large-scale websites and enterprise systems such as JD.com and Ctrip in actual applications.

Deepseek is a platform that provides anonymous deep network access. To access its official website, please use the official portal link provided. If you encounter problems during login, it may be due to the following reasons: the browser is outdated, the credentials are incorrect, the connection is blocked, maintenance or the account is disabled. Frequently Asked Questions include: Deepseek's security and legality, and how to connect with the support team.
