Home  >  Article  >  php教程  >  Example analysis of _initialize method in thinkPHP

Example analysis of _initialize method in thinkPHP

高洛峰
高洛峰Original
2016-12-30 09:43:111141browse

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();

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


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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn