exception throw from __autoload could not be catched on php 5.3.1

exception throw from __autoload could not be catched on php 5.3.1

am 29.01.2010 06:02:20 von Eric Lee

--0016e68ea05b4f9a98047e468a5e
Content-Type: text/plain; charset=UTF-8

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,

--0016e68ea05b4f9a98047e468a5e--

Re: exception throw from __autoload could not be catched onphp 5.3.1

am 29.01.2010 06:12:05 von Ashley Sheridan

--=-XTkSXdgGPCayi3GmBTmx
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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,


What version of PHP are you using? The example will only work on PHP
version 5.3.0 and above

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-XTkSXdgGPCayi3GmBTmx--

Re: exception throw from __autoload could not be catched onphp 5.3.1

am 29.01.2010 06:19:42 von Ashley Sheridan

--=-H/p9Zvx0RW6jaZ8ob7wp
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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
, was that intentional?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-H/p9Zvx0RW6jaZ8ob7wp--

Re: exception throw from __autoload could not be catched onphp 5.3.1

am 29.01.2010 06:27:42 von Ryan Sun

ÓÚ 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
> , 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

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

Re: exception throw from __autoload could not be catched on php

am 29.01.2010 06:28:05 von Eric Lee

--001636c5c2b26865e4047e46e696
Content-Type: text/plain; charset=UTF-8

On Fri, Jan 29, 2010 at 1:19 PM, Ashley Sheridan
wrote:

> 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
> , was that intentional?
>

Sorry for that ! I'am too lazy !!
And that's just for easy looking the code.

I actually use this,


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";
}



?>


Regards,
Eric,


>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

--001636c5c2b26865e4047e46e696--

Re: exception throw from __autoload could not be catched on php

am 29.01.2010 06:40:01 von Eric Lee

--00163623a9d71938af047e47118c
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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

> äº=8E 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 th=
e
> >> manual.
> >>
> >> Here are the code segment.
> >>
> >> [[[
> >> function __autoload($name) {
> >> echo "Want to load $name.\n";
> >> throw new Exception("Unable to load $name.");
> >> }
> >>
> >> try {
> >> $obj =3D 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 fo=
r
> > running the example. I do notice that you've got [[[ and ]]] in-place o=
f
> > , 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
>

--00163623a9d71938af047e47118c--