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!
blog comments powered by Disqus |
|
|
|
|
|
|
|