News Feed
Sections




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

O'Reilly:
Code As Data Reflection in PHP
April 26, 2007 @ 13:19:32

On O'Reilly's ONLamp.com website today, there's a new tutorial that focuses on something new to PHP's functionality as of the PHP 5 releases - the Reflection API - and examples of using "code as data".

However, this can get difficult very quickly, as modern "P" languages often are quite complex, and creating a solid set of regular expressions to describe PHP or Perl would be very difficult. Many syntax highlighters have problems relating to here documents and other special cases. It would be better to let the language's own parser take care of the hard part, as it already knows how to parse itself. In PHP (version 5 and later), we can use the Reflection API to do this.

As they explain, the Reflection API allows PHP code to look at other PHP code and find out things about it - things like function information, where and what objects are made and much more. In their code example, they create a class to parse a class, grabbing what type each of the methods are, their names, what parameters they take in, and finally, outputting the results as an XML document.

Then, using an Ajax frontend to call some backend scripts (corresponding to grabbing various data about a file) to perform some tests on their sample class, including the creation of a class to build the tests themselves.

0 comments voice your opinion now!
data reflection php5 tutorial test data reflection php5 tutorial test


blog comments powered by Disqus

Similar Posts

SitePoint PHP Blog: Build Virtual Machines Easily with PuPHPet Part 2

XPertDeveloper.com: Get Facebook Page Detail Using Graph API and PHP

php|architect: The Magic __set_state Method

PHPMaster.com: Bulletproofing Database Interactions with PHPUnit's Database Extension

DevShed: Creating a MySQL Abstraction Layer with Bridge Classes in PHP 5


Community Events

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


library conference podcast php7 performance install introduction example extension release version interview community voicesoftheelephpant api laravel opinion series symfony2 framework

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