class Person { public $name = "John"; protected $age = 30; private $city = "New York"; } $person = new Person(); $property = new ReflectionProperty("Person", "name"); $value = $property->getValue($person); echo $value; // Output: John $property = new ReflectionProperty("Person", "age"); $property->setAccessible(true); $value = $property->getValue($person); echo $value; // Output: 30In the above example, we create a new instance of the Person class and use the ReflectionProperty class to retrieve the value of the $name and $age properties. The getValue method is used to extract the values of these properties from the $person object. At the same time, we use the setAccessible method to override the access level of the $age property to allow it to be accessed even though it is protected. The package library for the ReflectionProperty class is part of the PHP core library and does not require any additional installation or configuration.