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?