문제

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