Re: exception throw from __autoload could not be catched on php 5.3.1
| From: | Eric Lee | Date: | Fri, 29 Jan 2010 05:40:01 +0000 |
| Subject: | Re: exception throw from __autoload could not be catched on php 5.3.1 | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301646@lists.php.net to get a copy of this message | ||
Hi all and thanks for Ryan,
I apologize ! !
I have missed out the small class_exists call before it.
Thanks.
Regards,
Eric,
2010/1/29 Ryan <ryansun81@gmail.com>
> 于 2010-1-29 13:19, Ashley Sheridan 写道:
> > On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote:
> >
> >
> >> 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,
> >>
> >
> > Sorry, ignore that, I see you're running 5.3.1, which should be fine for
> > running the example. I do notice that you've got [[[ and ]]] in-place of
> > <?php and ?>, was that intentional?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> >
> Do you have any other autoload implamentaions? try testing that code
> segment in a single php file and dump phpinfo() to make sure you are on
> php 5.3.1
>