SunshinePHP Developer Conference 2015

ReflectionProperty::setValue

(PHP 5)

ReflectionProperty::setValueتعیین مقدار خاصیت

Description

public void ReflectionProperty::setValue ( object $object , mixed $value )

تعیین مقدار خاصیت.

Warning

This function is currently not documented; only its argument list is available.

Parameters

object

نام شی.

value

نام مقدار.

Return Values

No value is returned.

See Also

add a note add a note

User Contributed Notes 1 note

up
0
me at ircmaxell dot om
3 years ago
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"
?>
To Top