PHP 函数 get_class_vars()


PHP 函数 get_class_vars()

<?php
   class helloworld {
      var $var1;
      var $var2 = "xyz";
      var $var3 = 100;
      private $var4; // PHP 5

      function helloworld() {
         $this->var1 = "foo";
         $this->var2 = "bar";
         return true;
      }
   }

   $hello_class = new helloworld();
   $class_vars = get_class_vars(get_class($hello_class));

   foreach ($class_vars as $name => $value) {
      echo "$name : $value \n";
   }
?>