PHP 8.5.0 Alpha 4 available for testing

Voting

: four plus one?
(Example: nine)

The Note You're Voting On

matthieu at mnapoli dot fr
12 years ago
Note that the property will only become accessible using the ReflectionProperty class. The property is still private or protected in the class instances.

<?php
class MyClass {
private
$myProperty = true;
}

$class = new ReflectionClass("MyClass");
$property = $class->getProperty("myProperty");
$property->setAccessible(true);

$obj = new MyClass();
echo
$property->getValue($obj); // Works
echo $obj->myProperty; // Doesn't work (error)
?>

<< Back to user notes page

To Top