ThinkPHP calls the common/common. php function and prompts the error function undefined. thinkphpcommon. php

Source: Internet
Author: User

ThinkPHP calls the common/common. php function and prompts the error function undefined. thinkphpcommon. php

This article describes how ThinkPHP calls the common/common. php function and prompts the error function undefined. For those who use ThinkPHP for project development, ThinkPHP upgrades often encounter such problems. The detailed description is as follows:

After ThinkPHP is upgraded, the latest ThinkPHP3.2 version is used to put common functions into common/common. php. However, the function undefined error message is displayed when the function is called on a specific page.

After checking the official documentation, we found that the original ThinkPHP3.2 common. php file has been renamed function. php,
So change common. php ---> to function. php. The function is successfully called! Solve the problem!

I hope this method will be helpful for ThinkPHP development.


Methods In the common folder in the thinkphp Project

1. How to name the common folder in thinkphp:
Create a common. php file under the common folder (this is fixed)
->
You can customize functions in the common. php file, such as function aa ($ str) {...}. The function name is random and the parameters are random.
->
There are two points about how to use it. One is the controller (that is, Action, such as loginAction. class. php), you can directly call a function, such as aa ($ title); the other is in the template file, which must be separated by "|", such as {$ title | aa}
->
Most importantly, you need to delete ~ App. php file, because common. php is first parsed ~ In the app. php file, and then called.

2. This is simple, such as class IndexAction extends LoginAction {...}, note: I generally use uppercase letters for Action naming, but I don't know if I can use lowercase letters. It is recommended that I use uppercase letters for the corresponding Model name.

How does one define and call a custom function in thinkphp?

Common/common. php can be written in this file directly in the method! You can write your own method! But you need to call the file you wrote when using your method! There is also whether thinkphp is a single module portal. Find their files and reference your files in them! In this way, you can use it directly !!!!
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.