From: Eric Lee on 29 Jan 2010 00:08 Hi php-dev pros, I got an issue about catching exception throw from __autoload on php 5.3.1. The manual state that exception throw from __autoload could be catched with try.. catch statement same as the normal flow. But I'can archive that even I have copied the same sample code from the manual. Here are the code segment. [[[ function __autoload($name) { echo "Want to load $name.\n"; throw new Exception("Unable to load $name."); } try { $obj = new NonLoadableClass(); } catch (Exception $e) { echo $e->getMessage(), "\n"; } ]]] Are there anyone experienced this or not ? Thanks in advance ! Regards, Eric,
From: Eric Lee on 29 Jan 2010 02:25 Don. I'am sorry that the issue have been solved and that is due to I missed something in the code ! ! And it works fine now. Thanks for you help ! ! Regards, Eric, On Fri, Jan 29, 2010 at 2:08 PM, Venkat Raman Don <Don.Raman(a)microsoft.com>wrote: > On second thought, the output I am getting: > > Want to load NonLoadableClass. Unable to load NonLoadableClass. > > is consistent with the example on php.net ( > http://php.net/manual/en/language.oop5.autoload.php ). > > So sorry about previous mail. This is not reproing for me. Are you running > it using PHP command line? This is not supported in CLI mode. Can you paste > the output you are getting? > > I modified the program to: > > <?php > > function __autoload($name) { > echo "Want to load $name.\n"; > throw new Exception("Unable to load $name."); } > > try { > $obj = new NonLoadableClass(); > } catch (Exception $e) { > echo "Don\n"; > echo $e->getMessage(), "\n"; > } > > ?> > > And I get the output as: > Want to load NonLoadableClass. Don Unable to load NonLoadableClass. > > So I can see 'Don' getting printed in the browser. Please let us know the > output you are getting. > > Thanks, > Don. > > -----Original Message----- > From: Venkat Raman Don [mailto:Don.Raman(a)microsoft.com] > Sent: Thursday, January 28, 2010 9:48 PM > To: Eric Lee; php-windows(a)lists.php.net > Subject: RE: [PHP-WIN] exception throw from __autoload could not be catched > on php 5.3.1 > > Yes, I am also able to reproduce this in the browser using both 5.3.1 as > well as 5.3.0 on Windows using IIS. > > Seems like a bug. > > You may like to file the bug at http://bugs.php.net. > > Thanks, > Don. > > -----Original Message----- > From: Eric Lee [mailto:pgeric(a)gmail.com] > Sent: Thursday, January 28, 2010 9:09 PM > To: php-windows(a)lists.php.net > Subject: [PHP-WIN] exception throw from __autoload could not be catched on > php 5.3.1 > > Hi php-dev pros, > > I got an issue about catching exception throw from __autoload on php 5.3.1. > > The manual state that exception throw from __autoload could be catched with > try.. catch statement same as the normal flow. > > But I'can archive that even I have copied the same sample code from the > manual. > > Here are the code segment. > > [[[ > function __autoload($name) { > echo "Want to load $name.\n"; > throw new Exception("Unable to load $name."); > } > > try { > $obj = new NonLoadableClass(); > } catch (Exception $e) { > echo $e->getMessage(), "\n"; > } > > ]]] > > Are there anyone experienced this or not ? > > Thanks in advance ! > > Regards, > Eric, >
|
Pages: 1 Prev: 64-bit PHP binaries Next: exception throw from __autoload could not be catchedon php 5.3.1 |