How do I load common functions at the front and back ends of thinkphp? -Php Tutorial

Source: Internet
Author: User
How do I load common functions at the front and back ends of thinkphp? A website is built with thinkphp, which is divided into the front-end and backend (the project is not grouped). There are two portals, the front-end entry index. php backend entry admin. php

I would like to ask how to load common functions at the front and back ends. for example, time functions are used at the front and back ends, and all time functions are stored in the lib_time.php file, how can I load this file while the system is running, instead of loading it when it is used?


Reply to discussion (solution)

Generally, the website has a config file, which can be loaded.

Add
"LOAD_EXT_FILE" => "user"
The above settings will automatically load the extension function library file user under the Common public directory of the project during execution. php, so that you can directly call the extension function library user in the project. php functions, and the function modification of the extended function library takes effect in real time.

Alternatively, you can directly write it to the common. php file under the library on folder.

Directly write the method in Common/commnet. php. when the program runs, the file will be automatically loaded, and the method name can be called directly.

Thanks for your help. I am prompted to load public files in ThinkPHP/common/runtime. in php, the functions defined in the public files used in the front and backend of lib_common are C () and M (). For example, the execution of these functions is placed in runtime. think: Start (); of php,

Add
"LOAD_EXT_FILE" => "user"
The above settings will automatically load the extension function library file user under the Common public directory of the project during execution. php, so that you can directly call the extension function library user in the project. php functions, and the function modification of the extended function library takes effect in real time. "LOAD_EXT_FILE" => "user" is used in the configuration file of the project. the function in php should not set user. copy two copies of php and put them under the common/of both foreground and background projects. Do I have to write two copies of the configuration file?

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.