Home> php教程> PHP开发> body text

Example analysis of _initialize method in thinkPHP

高洛峰
Release: 2016-12-30 09:43:11
Original
1183 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!