Php, how to pass a class reference to a method? -



Php, how to pass a class reference to a method? -

this question has reply here:

php: dynamic or programmatic grab blocks 1 reply asserttriggerthisexception ('exception'); asserttriggerthisexception ('anotherexceptionclass'); function asserttriggerthisexception ($exceptionclassname) { seek { triggers exception } grab ($$exceptionclassname $e) // error { } }

so want pass reference class itself, causes syntax error. want "dinamically" expect exception, there way?

i think can seek

$someclass = 'someexception'; seek { $some->thing(); } grab (exception $e) { switch (get_class($e)) { case $someclass: echo 'dynamic exception.'; break; default: echo 'normal exception.'; } }

php

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -