Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has PHP's attitude towards exceptions changed in version 5.4.10? [closed]

Tags:

php

The following would work in PHP 5.3, but not in PHP 5.4.10.

throw new Custom_Exception();

class Custom_Exception extends Exception {}

PHP 5.4.10 would respond with the following fatal error:

Class 'Custom_Exception' not found in ...

Does anyone know why?

p.s. Moving the class definition above the throw statement fixes it.

like image 304
Emanuil Rusev Avatar asked Feb 25 '13 23:02

Emanuil Rusev


People also ask

What was the attitude regarding war in 1918?

1917-1918↑ Military disintegration and unwillingness to fight, mixed, in the later stages of the war, with growing vocal, ideological and politicized opposition to the very nature and existence of the conflict.

What were three reasons why an Australian might have wanted to enlist?

Initially, Australian men volunteered to enlist for different reasons, because they: needed regular pay. sought combat or adventure. wanted to escape from normal life.

What are people's perceptions of war in 1914?

What are people's perceptions of war in 1914? What were their expectations? People thought marching off to war would be fun or romantic so young men signed up without a second thought. Everyone thought it would be over by Christmas since they believed troops would fight in an open field.


1 Answers

I put your code into a file called test.php, and downloaded php-5.4.10

When I execute:

php -c php.ini-development -f test.php

I see the following output:

PHP Fatal error:  Uncaught exception 'Custom_Exception' in test.php:3
Stack trace:
#0 {main}
  thrown in test.php on line 3

Fatal error: Uncaught exception 'Custom_Exception' in test.php:3
Stack trace:
#0 {main}
  thrown in test.php on line 3

I believe you have a configuration issue. Are you testing from the command-line?

Edit:

I also compared do_bind_inherited_class in zend_compile.c for both versions.

zend_compile.c from 5.3

zend_compile.c from 5.4.10

It looks like they only added support for traits.

My answer is: No, I do not believe the attitude has changed.

like image 74
Martin Avatar answered Oct 30 '22 11:10

Martin