Exception not being caught

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So, I've got a little piece of code designed to play with catching the
exception that's thrown when an object doesn't have a __toString
method.

<?php

class A { }

$a = new A();                           // Ayn would be proud, right?

try {
    echo "a is ",$a,"\n";
} catch(Exception $e) {
    echo "\nException Caught: ";
    echo $e, $n;
}

?>

This does not run as expected. I'd think that when the implicit string
conversion in the try block hits, the exception would be thrown,
caught by the catch block, and relayed.

Instead you don't ever see the words "exception caught" and you get
"Catchable fatal error: Object of class A could not be converted to
string."

If it's catchable, why isn't it caught in my example?

Thanks,

Weston

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux