note 104550 added to reflectionproperty.setvalue

From: Date: Wed, 22 Jun 2011 16:27:47 +0000
Subject: note 104550 added to reflectionproperty.setvalue
Groups: php.notes 
Request: Send a blank email to php-notes+get-180848@lists.php.net to get a copy of this message
You can use ReflectionProperty::setValue to set the value on static properties as well as regular instance properties. Simply pass null in place of the instance: <?php class Foo { protected static $bar = null; public static function sayBar() { echo self::$bar; } } $r = new ReflectionProperty('Foo', 'bar'); $r->setAccessible(true); $r->setValue(null, 'foo'); Foo::sayBar(); // "foo" ?> ---- Server IP: 208.69.120.55 Probable Submitter: 64.210.199.232 ---- Manual Page -- http://www.php.net/manual/en/reflectionproperty.setvalue.php Edit -- https://master.php.net/note/edit/104550 Del: integrated -- https://master.php.net/note/delete/104550/integrated Del: useless -- https://master.php.net/note/delete/104550/useless Del: bad code -- https://master.php.net/note/delete/104550/bad+code Del: spam -- https://master.php.net/note/delete/104550/spam Del: non-english -- https://master.php.net/note/delete/104550/non-english Del: in docs -- https://master.php.net/note/delete/104550/in+docs Del: other reasons-- https://master.php.net/note/delete/104550 Reject -- https://master.php.net/note/reject/104550 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180848) next »