質問

I have a couple of exception ex:

fooException extends Exception{}
barException extends Exception{}
tarException extends Exception{}

here is the exception handler

 set_exception_handler('get_exceptions');

  function get_exceptions($msg){
    # how to get the exception name here like
    # fooException barException
  }

example errors

 if(0){
    throw new fooException;  
 }

 if(!1){
   throw new barException;  
 }

Now, inside the get_exceptions function I am trying but unable to get what exception type that is being thrown, instead of the the message, code and the whole data. just the name of the class, like fooException or barException is there anyway to get only the name of the triggered exception ?

役に立ちましたか?

解決

try

$exceptionClass = get_class($msg);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top