The example in this article describes the _initialize method in thinkPHP. Share it with everyone for your reference, the details are as follows:
The _initialize method of the subclass automatically calls the _initialize method of the parent class. As for PHP's constructor construct, if you want to call a method of the parent class, you must explicitly call parent::__construct();
Copy after login
If the subclass does not have an _initialize method in the subclass constructor , the _initialize method of the parent class is called by default.
Output: Base class
If there is, execute your own _initialize method.
Output: hello I am child
If executed simultaneously, write like this
Copy after login
Output: Base class hello I am child
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.
For more articles related to example analysis of the _initialize method in thinkPHP, please pay attention to the PHP Chinese website!