PHP – get class name of an object
get_class with object as arguments returns its class name.
<?php class Class1 { } $obj = new Class1(); echo "class name of obj=" . get_class($obj); ?>
class name of obj=Class1
Env: PHP 7.4.33 (Linux)
PHP – get filename from class name
<?php $classname = 'WP_Query'; $reflector = new ReflectionClass($classname); echo $reflector->getFileName(); ?>
Here is the outcome from above code:
/path_to_word_press_root/wp-includes/query.php
Note: This can be useful to debug large code base.