News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Springboard Software Blog:
Using Introspection in PHP
June 27, 2006 @ 11:48:01

In this new post on the Springboard Software blog today, Michael takes a look at a very handy feature that PHP has to offer those working with objects - a form of introspection.

One of the things we love about Java is its ability to use introspection. Don't know what methods or field an object has? Just ask it.

It turns out that PHP provides some nifty introspection features as well. We've found one to be particularly useful: the ability of a PHP object to tell us its member variables at runtime. Not sure what that means? Let's look at an example.

In his example, he uses a content management system, specifically the "business objects" to illustrate his point. Introspection comes into play when the get_class_vars function is called, returning the defined variables for an object and allowing one to feed in values to be automagically set (in this case, either an array, a request, or a primary key for a record from the database).

0 comments voice your opinion now!
introspection objects businessobject get_class_vars get_class introspection objects businessobject get_class_vars get_class


blog comments powered by Disqus

Similar Posts

Maarten Balliauw's Blog: A client side Glimpse to your PHP application

Zend Developer Zone: Book Review: Learning PHP Data Objects

Zend Developer Zone: Sebastian Bergmann on ZendCon and PHPUnit 3

DevShed: Controlling Online Forms with Builder Objects in PHP 5 (Part 2)

Wez Furlong's Blog: SDO, SOA, TLA?


Community Events

Don't see your event here?
Let us know!


conference symfony2 release laravel framework series part2 example api opinion introduction application configure voicesoftheelephpant community language performance php7 podcast interview

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework