- method_exists: documentation ( source)
<?php
class myCustomException extends Exception {
}
class someClass {
public function __call($name, $arguments) {
if (!method_exists($this, $name)) {
throw new myCustomException($name . ' has shuffled the mortal coil');
}
}
}
$someObject = new someClass();
try {
$someObject->someMethodTheObjectDoesntProvide();
} catch (myCustomException $e) {
echo $e->getMessage();
}