PHP
  Home arrow PHP arrow The Reflection API: Working with Reflected Methods
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

The Reflection API: Working with Reflected Methods


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


    Table of Contents:
  • The Reflection API: Working with Reflected Methods
  • Review: using the PHP reflection API to retrieve information on a class
  • Retrieving methods of a reflected class
  • Getting all the public methods of a reflected class

  • 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: This third part of a seven-part series explores the methods of the PHP Reflection API. You will learn how to take advantage of their functionality to retrieve useful information about the methods defined by a reflected class.

    The Reflection API: Working with Reflected Methods
    (Page 1 of 4 )

    One of today's most powerful approaches for retrieving information about the internal structure of classes and interfaces in PHP 5 is via the language's native reflection API. What's more, not only does this API comes packaged with a huge variety of methods that let developers perform all sorts of reverse-engineering tasks using an object-oriented approach, but it offers a flat learning curve.

    In reality, knowing whether a method within a specified class is public, protected or private, or determining whether or not a declared property is static, only involves invoking the proper method provided by the API. The entire introspection process is that easy.

    Naturally, if you've already read the two previous parts of this series, you're now pretty familiar with using the PHP reflection API to get basic data on a simple interface and its implementing class. In those two articles I demonstrated how to retrieve, for instance, the name, the default properties and constants of a sample reflected class. I also showed how to discover a few other minor details, such as its physical location within the file system.

    As I said a moment ago, however, the API provides many other helpful methods for obtaining relevant information about a specific class. These include methods that allow you to know what methods are defined by the class, and their level of visibility.

    Assuming that you're interested in learning more about this topic, in the lines to come I'm going to show you how to manipulate reflected methods in a painless way. This process will range from finding out if they're public, protected or private, to invoking them (when possible) directly from client code.

    Now it's time to learn a few more useful things about the PHP reflection API. Let's go!



     
     
    >>> 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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek