Zitat von rkr
Beitrag anzeigen
PHP-Code:
class Foo
{
private $privateVal;
public function __construct( $val )
{
$this->privateVal = $val;
}
}
$foo = new Foo( 17 );
$refClass = new ReflectionClass( $foo );
$refProperty = $refClass->getProperty('privateVal');
$refProperty->setAccessible( true );
$refProperty->setValue( $foo, 42 );
print_r( $foo );
Gruß, Ulf
Kommentar