- is_callable: documentation ( source)
<?php
function test($var) {
echo "Testing: $var\n";
}
class foo {
var $baz = "test";
function bar( $str ) {
if( is_callable( $this->baz )) {
$this->baz( $str );
}
}
}
$foo = new foo;
try {
$foo->bar("bla"); // fatal error
} catch (Error $e){
echo "Whoops -- ", $e->getMessage();
echo "\nEnd of Script :)";
}