About the constructor in the controller class in thinkphp
Public function _ construct () {Hook: listen ('Action _ in ', $ this-> config); // instantiate the view class $ this-> view = Think :: instance ('think \ view'); // The controller initializes if (method_exists ($ this, '_ initialize') $ this-> _ initialize ();}
This is the controller class constructor code in the tp framework.
View should be introduced into the controller through this function, but how is the Hook class and Think class introduced into the controller class.
Can I directly use the Hook class or Think class without any use or require?
Reply to discussion (solution)
ThinkPHP first executes the Think class in Think. class. php.
There are
Spl_autoload_register ('think \ Think: autoload ');
Registered methods for automatically loading class files
This method will be called to load classes that are not in the memory.
ThinkPHP first executes the Think class in Think. class. php.
There are
Spl_autoload_register ('think \ Think: autoload ');
Registered methods for automatically loading class files
This method will be called to load classes that are not in the memory.
Found... I feel that the tp framework is well designed .....
Can the moderator explain how thinkphp makes Think class in Think. class. php run first?
Project entry:
/// + Outputs // application entry file // Check the PHP environment if (version_compare (PHP_VERSION, '5. 3.0 ',' <') die ('require PHP> 5.3.0! '); // Enable the debugging mode. it is recommended that you enable the annotation of the deployment phase in the development phase or set it to falsedefine ('app _ debug', True ); // define the application directory define ('app _ path ','. /Application/'); // introduce the ThinkPHP entry file require '. /ThinkPHP. php '; // It's so simple that no code is needed in the end
The last line of the ThinkPHP. php file is
Think\Think::start();
In this way, the entire system will be activated.
Project entry:
/// + Outputs // application entry file // Check the PHP environment if (version_compare (PHP_VERSION, '5. 3.0 ',' <') die ('require PHP> 5.3.0! '); // Enable the debugging mode. it is recommended that you enable the annotation of the deployment phase in the development phase or set it to falsedefine ('app _ debug', True ); // define the application directory define ('app _ path ','. /Application/'); // introduce the ThinkPHP entry file require '. /ThinkPHP. php '; // It's so simple that no code is needed in the end
The last line of the ThinkPHP. php file is
Think\Think::start();
In this way, the entire system will be activated.
O (∩) O thank you