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

PHP 怎么获取protected属性

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:41:36
Original
880 people have browsed it

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属性的字段的值。 

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