Scenario: I have a class that extends another class, yet the parent class is undefined (for whatever reason). I am trying to get a ReflectionClass of the child class. When I do this, I get a Class Not Found exception on the parent class. However, I cannot catch this exception. What am I doing wrong?
For example...
<?php
class Foo extends Bar { }
try
{
    $class = new ReflectionClass('Foo');
    echo 'I\'ve reflected "Foo" successfully!';
开发者_开发问答}
catch (Exception $e)
{
    echo 'My exception handler';
}
The result of the above code is a printout of the class 'Bar' not found exception. Why is my catch statement not picking up the exception?
thanks, Kyle
That's because the exception occurred on this line and not on the lines after try:
class Foo extends Bar { }
I tried it, putting the class declaration on a try-catch won't work too. Make sure Bar is included first.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论