3 function my_handler($errno, $errstr, $file, $line) {
4 throw new Exception($errstr);
7 function try_takes_num($a) {
10 } catch (Exception
$e) {
11 echo $e->getMessage(), "\n";
15 function takes_num(num
$a) {
19 class NumericallyStringable
{
20 function __toString() {
29 try_takes_num('10.5'); // nope: no strings, even numeric
30 try_takes_num('foo'); // nope: string
31 try_takes_num(new NumericallyStringable()); // nope: object
32 try_takes_num(new StdClass()); // nope: object
35 set_error_handler('my_handler');