#44827 [Ver->Asn]: define('::') can be defined

From: Date: Sun, 19 Oct 2008 18:28:48 +0000
Subject: #44827 [Ver->Asn]: define('::') can be defined
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129850@lists.php.net to get a copy of this message
ID: 44827 Updated by: felipe@php.net Reported By: kalle@php.net -Status: Verified +Status: Assigned Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.2.6 -Assigned To: +Assigned To: iliaa Previous Comments: ------------------------------------------------------------------------ [2008-04-25 10:11:39] kalle@php.net As a note to this while we're at define(). define() also seems to ignore if you declare a class constant like: define('test::c', 'test'); Both with and without having a class called 'test' passes this, testing without the class 'test' like: var_dump(test::c); Will result in a fatal error: class 'test' not found. Testing it with a class called 'test' will issue a fatal error: undefined class constant 'c'. If the class 'test' already have a constant called 'c' define() will still ignore it and var_dump() will return the real value of test::c. ------------------------------------------------------------------------ [2008-04-25 10:01:38] kalle@php.net Description: ------------ PHP (5.2.5) allows you to define '::' as a constant without issuing an E_WARNING, below examples will demonstrate it. The constant() function will issue an fatal error when recieving '::' as constant name: Fatal error: Class '' not found in C:\webserver\www\gd\gd.php on line 91 Which might also be wrong or confusing to the programmer Reproduce code: --------------- <?php define('::', true); var_dump(constant('::')); ?> Expected result: ---------------- A fatal error for each of the calls: Fatal error: Invalid constant name in test.php on line 2 Fatal error: Invalid constant name in test.php on line 3 Actual result: -------------- Fatal error: Class '' not found in C:\webserver\www\gd\gd.php on line 91 None warning or fatal error for define()... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44827&edit=1

« previous php.bugs (#129850) next »