class MyClass { public $public_var = 'Public variable'; protected $protected_var = 'Protected variable'; private $private_var = 'Private variable'; } $class = new ReflectionClass('MyClass'); $default_properties = $class->getDefaultProperties(); print_r($default_properties); // Output: // Array ( // [public_var] => Public variable // [protected_var] => Protected variable // [private_var] => Private variable // )
$class = new ReflectionClass('SomeClass'); $filename = $class->getFileName(); if (strpos($filename, '/vendor/') !== false) { echo 'Class belongs to a package/library.'; } else { echo 'Class does not belong to a package/library.'; }In this example, we use the `ReflectionClass` to get the filename of a class called `SomeClass`. We check if the filename contains the string `/vendor/`, which is usually an indication that the class belongs to a package/library. If it does, we print a message saying that the class belongs to a package/library. If not, we print a message saying that it does not belong to a package/library.