Home  >  Article  >  Backend Development  >  PHP 怎么获取protected属性

PHP 怎么获取protected属性

WBOY
WBOYOriginal
2016-06-13 12:41:36815browse

PHP 如何获取protected属性?
class userVo extends model {
  protected $userid = array(.....); 

  protected $username = array(.....);
  
  .........
}


class model{

 public function getVoProtectedProperties(){
 
  如何获取userVo(对象而不是类) 内的protected属性?
     $this指向子类实例 
 }
}



class Action {
  public function init(){
      $uservo = new userVo(); 
      $uservo->getVoProtectedProperties();
 }
}

-------------------------
不想使用: $class_date = new ReflectionClass(get_class($this)); 来得到属性。 
能不能直接得到对象的所有protected属性的字段的值。 

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