PHP
  Home arrow PHP arrow Getting Information on a Reflected Class with the Reflection API
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
iPad news and developer info.
Ads by affinity 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
VPS Hosting 
Forums Sitemap 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Getting Information on a Reflected Class with the Reflection API


By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2010-03-03


    Table of Contents:
  • Getting Information on a Reflected Class with the Reflection API
  • Review: using the PHP 5 reflection API
  • The getDefaultProperties() and getDocComment() reflection methods
  • The getStartLine(), getEndLine() and getFileName() methods

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Summary: In this second part of a series, I explore some handy methods of the PHP Reflection API. They allow you to retrieve miscellaneous information about a class, including its name and containing file, as well as its starting and ending lines.

    Getting Information on a Reflected Class with the Reflection API
    (Page 1 of 4 )

    Overlooked by many developers, the Reflection API that comes with PHP 5 is a powerful reverse-engineering extension of the language that permits developers to analyze, inspect and retrieve valuable information about selected classes and interfaces by means of a set of convenient methods.

    So, if you’re a PHP programmer interested in learning how to put this API to work for you, then this article series might be the material that you’re looking for. In its tutorials you’ll be provided with a decent number of code samples aimed at demonstrating how to use the most relevant reflective methods included with the API.

    And now that you’ve been introduced to the goal of the series, it’s time to review the topics that were discussed in the first installment, taking into account the possibility that you haven’t read it yet. So, to put it simply, in that article I coded a couple of scripts that showed how to obtain the name of a reflected class and the values assigned to its unique constant via the “getName(),” getConstant()” and “getConstants()” reflection methods.

    Despite their simplicity, these introductory examples demonstrated the remarkable introspective capabilities offered by the reflection API when used in an object-oriented environment. However, as you might have guessed, the API comes bundled with many other methods that deserve a close analysis as well.

    With that premise in mind, in this second episode of the series I’m going to show you how to get miscellaneous information about a reflected class, including things like its starting and ending lines within its containing file, the interfaces that the class implements, and so forth.

    Now, let’s leave the preliminaries behind us and continue to explore a few more handy methods provided by the PHP 5 reflection API. Let’s get going!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - MVC and the Zend Framework
    - PHP: Rendering Web Pages Using the Composite...
    - PHP: Creating Dynamic Web Pages with the Com...
    - Secure Encrypting and Decrypting for Your PH...
    - PHP: Creating Single View Objects with the C...
    - PHP: View Object Collections and the Composi...
    - Securing Your PHP Website
    - Determine Link Relevance and Unique Class C ...
    - PHP Composite View Design Pattern: Introduci...
    - Facebook PHP API Applications: A Second Look
    - Secure PHP Programming
    - Facebook PHP API Applications: Basic Introdu...
    - SOAP Servers and Web Services
    - Using XPath, SOAP, and More with Web Services
    - Web Services: SimpleXML


    Code Analysis Tools
    Enterprise code analysis tools that deliver quality and reliable code

     


     


    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek