|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-05-11 12:12 UTC] iliavlad at mail dot ru
Description:
------------
constant() failed to check undefined constant and php interpreter stoped, but constant() should return NULL and php interpreter should continue to work.
Test script:
---------------
class A
{
const B = 1;
}
var_dump(constant('A::B1'));
echo 5;
Expected result:
----------------
Warning: constant(): Couldn't find constant A::B1
NULL
5
Actual result:
--------------
>php -v
PHP 5.3.2 (cli) (built: Mar 3 2010 19:40:13)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
>php -r "class A { const B = 1;} var_dump(@constant('A::B1')); echo 5;"
>php -r "class A { const B = 1;} var_dump(constant('A::B1')); echo 5;"
Fatal error: Undefined class constant 'A::B1' in Command line code on line 1
Call Stack:
0.0003 317608 1. {main}() Command line code:0
0.0003 317688 2. constant() Command line code:1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 00:00:02 2025 UTC |
constant('not::exists') was issuing an E_FATAL.