HomePHP 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.
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
echo 'Reflected class is internal'; // displays 'Reflected class is not internal'
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!