Home  >  Article  >  Backend Development  >  ThinkPHP calls common/common.php function prompts error function undefined solution, thinkphpcommon.php_PHP tutorial

ThinkPHP calls common/common.php function prompts error function undefined solution, thinkphpcommon.php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:20:001448browse

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.

Methods in the common folder in the thinkphp project

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.

How to define and call custom functions in thinkphp?

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! ! ! !

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/869452.htmlTechArticleThinkPHP calls the common/common.php function and prompts the error function undefined solution, thinkphpcommon.php This article mainly introduces ThinkPHP Calling the common/common.php function prompts an error functi...
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