I'm making the leap to OOP with my PHP. Is there a way to list all active classes and their methods and properties?
PHP | get_class_methods() Function The get_class_methods() function is an inbuilt function in PHP which is used to get the class method names. Parameters: This function accepts a single parameter $class_name which holds the class name or an object instance.
Once you have an object, you can use the -> notation to access methods and properties of the object: $object -> propertyname $object -> methodname ([ arg, ... ] ) Methods are functions, so they can take arguments and return a value: $clan = $rasmus->family('extended');
In PHP, a property is qualified by one of the access specifier keywords, public, private or protected. Name of property could be any valid label in PHP. Value of property can be different for each instance of class. That's why it is sometimes referred as instance variable.
Complete list of similar functions :)
Quick Look:
get_declared_classes() // gives you all declared classes
get_class_methods() // gives you all methods of class
get_class_vars() // gives you properties of the class
get_object_vars() // gives you propertis of an object
get_parent_class() // gives you parent class of the current class
Also, you might be interested in the Reflection API offered by PHP.
As they claim in their introduction:
PHP 5 comes with a complete reflection API that adds the ability to reverse-engineer classes, interfaces, functions, methods and extensions. Additionally, the reflection API offers ways to retrieve doc comments for functions, classes and methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With