Programming PHP the right way as with any other OOP language requires knowledge and understanding of OOP concepts. For those of you who don’t know this by now, OOP stand for Object Oriented Programming. Working on a small project where developer goes trough just a few files is a no problem since your most likely memorize all your properties and methods.
However, working with big project like Magento, or even WordPress can become real pain in a neck if u use only text editor trough your development process. On the other hand, don’t think your off the hook using some fancy IDE studio like NetBeans, NuSphere, or ZendStudio. Problem is that each of them has it’s own problems and glitches resolving object context across multiple project files and so on. Sometimes when you hit $this-> code completion wont return any methods that go with it. So what do you do?
My previous post, Debugging Magento using Krumo, was just a warmup. PHP enables you to use number of built in functions designed to give you necessary information about object context, public files available to that object and so on. If your a beginner or intermediate developer you might wonder why would someone need to know this. I mean no disrespect when calling on intermediate level programmers in same context as beginner level. The thing is, many of the PHP programmers can make extraordinary apps without even a slightest knowledge of OOP concepts. After all, OOP support in PHP is something that was added to design trough-ought the years.
Advanced programming requires you to know OOP concepts and their usage. Otherwise it would not be called advanced, right?
I mentioned before that PHP comes with builtin functions essential for quick retrieval of object information. Here are the functions you can use as your every day help to speed up thing.
- get_class($object); # returners string
- get_class_methods($class_name); # returners array
- get_class_vars($class_name); # returners array
- get_declared_classes(); # returners array
- get_declared_interfaces(); # returners array
- get_defined_constants(); # returners array
- get_defined_functions(); # returners array
- get_defined_vars(); # returners array
- get_included_files(); # returners array
- get_object_vars($object); # returners array
- get_parent_class(); or get_parent_class($object); # returners string
- get_required_files(); # returners array
- is_a($object, $class_name); # bool
- is_resource($var); # bool
- is_object($var); # bool
- is_subclass_of($object, $class_name); # bool
These are not all get_ or is_ functions available in PHP. I mentioned only those essential as a help to OOP.
One tip on executing all the get_ functions. Most of them you’ll have to echo to see the result in browser, like
<?php echo get_declared_classes(); ?>
Second tip is to var_dump() some of the get_ functions. Given the fact most of them return array as a result, echo would return “array” to browser. So you might do something like this
<?php var_dump(get_declared_classes()); ?>
to get nice output on your browser. Here are some screenshots for you to see.
You can even download sample project I made. All you need to do is to dump it into sour Apache web folder and run idex.php. Try playing around with commented functions.
I strongly recommend reading detailed information on each listed function in official PHP documentation.
Hope this article was helpful for some of you.




