Home > Backend Development > PHP Tutorial > tp5 model question

tp5 model question

WBOY
Release: 2016-10-22 12:06:44
Original
1054 people have browsed it

Initialization code in User model:
//Define the code for initialization call
protected function initialize(){

//Need to call the initialization method of the parent class
parent::initialize();

echo 'initialize-';

}

There is a loop in one of the methods GetUserList():
foreach($list as $key=>$user){
echo $user->user_name;
}

After controlling the calling method: GetUserList(), the output text is:
initialize-
initialized initialize-initialized initialize-initialized initialize-initialized initialize-

Question:
Will using $user -> user_name in foreach also trigger the model's initialize method again?

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template