php 面向对象
class test{ private $name; private $sex; function __construct(){ $this->aaa='aaa'; }}$test=new test();$reflect=new ReflectionClass($test);$pro=$reflect->getDefaultProperties();print_r($pro);//打印结果:Array ( [name] => [sex] => )echo $test->aaa;//打印结果:aaa 动态产生的对象属性是全局性的,这与变量无需声明就可访问是一脉相承的
但是由于一些学究的批评,php 开始逐渐放弃这种轻巧的表述方法了
所以,应该尽量不要这样做
动态产生的对象属性是全局性的,这与变量无需声明就可访问是一脉相承的
但是由于一些学究的批评,php 开始逐渐放弃这种轻巧的表述方法了
所以,应该尽量不要这样做
http://tanteng.sinaapp.com/2013/11/php-reflectionclass-object/
谢谢,已有比较完整的回答了。
http://tanteng.sinaapp.com/2013/11/php-reflectionclass-object/
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号