class Student { private $name; } $reflection = new ReflectionClass('Student'); if ($reflection->hasProperty('name')) { echo 'Property exists'; } else { echo 'Property does not exist'; }
Property exists
require_once('MyPackage/MyClass.php'); $reflection = new ReflectionClass('MyPackage\\MyClass'); if ($reflection->hasProperty('myProperty')) { echo 'Property exists'; } else { echo 'Property does not exist'; }
Property existsFrom the above example, we can determine that the package/library used is "MyPackage".