Home arrow PHP arrow Page 3 - Checking Native and User-Defined Classes with the Reflection API

Working with the isInternal() method - PHP

Welcome to the final part of a series on the Reflection API. Through a decent variety of functional code samples, this series shows you how to take advantage of the power offered by reflection to analyze the internal structure of your classes and interfaces by using an object-oriented approach.

TABLE OF CONTENTS:
  1. Checking Native and User-Defined Classes with the Reflection API
  2. Review: a quick look at some previous examples
  3. Working with the isInternal() method
  4. Checking native and user-defined classes with the isUserDefined() reflective method
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
April 05, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

As you may recall from the section that you just read, the reflection API provides yet another useful method that permits you to check whether or not a specified class is native. The method that does this is called ""isInternal()," and an example of how to use it has been included below:

// create instance of 'User' class

$user = new User();

 

 

// create instance of Reflection class and pass in 'User' class as an argument

 

 

$reflector = new ReflectionClass('User');

 

// check if the reflected class is internal

if ($reflector->isInternal())

{

    echo 'Reflected class is internal'; // displays 'Reflected class is not internal'

}

else

{

    echo 'Reflected class is not internal';

}

For obvious reasons, when used in conjunction with the sample "User" class, the "isInternal()" method will return a value of FALSE. However, you may be wondering if there's a complementary method that checks to see if the class is not internal, right? Well, fortunately the answer is yes; this one, not surprisingly, has been called "isUserDefined()."

Of course, if you're anything like me, it's probable that you want to see how to utilize this method in a concrete case. That's exactly what I'm going to do in the following section. Therefore, if you wish to learn how to use this additional reflective method, go ahead and click on the link below. We're almost finished here!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: