search

Home  >  Q&A  >  body text

When there is multiple user data, how to use classes to handle multiple

class usermodel{

public $userList;

public $id;

public $name;

public function _init(){

$this->userList=include_once './123.php';

}

public function get_name(){

return $this->name;

}

public function get_user_info($userid){

foreach($this-> userList as $user){

if($userid==$user['id']){

return $user;

}

}

}

}

$model=new usermodel();

$model->_init();

$userinfo=$model->get_user_info(3);

var_dump($userinfo);

In this question, how to use tools to process multiple data forever

落叶.落叶.1957 days ago864

reply all(0)I'll reply

No reply
  • Cancelreply