class MyClass { private $property; } $reflectionProperty = new ReflectionProperty('MyClass', 'property'); echo $reflectionProperty->getName();
class MyClass { private $property; } $obj = new MyClass(); $reflectionProperty = new ReflectionProperty($obj, 'property'); echo $reflectionProperty->getName();This code will also output "property". The ReflectionProperty class is part of the PHP core library.