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 replyasserttriggerthisexception ('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
Post a Comment