源代码:
color = $color; } function what_color() { return $this->color; } } function print_vars($obj) { foreach (get_object_vars($obj) as $prop => $val) { echo " $prop = $val "; } } // instantiate one object $herbie = new Car("white"); // show herbie properties echo "herbie: Properties "; print_vars($herbie); ?>
运行结果: