Bug #77100 [NEW]: Inconsistent behavior between constants and magic constants

From: Date: Sat, 03 Nov 2018 16:12:35 +0000
Subject: Bug #77100 [NEW]: Inconsistent behavior between constants and magic constants
Groups: php.standards 
Request: Send a blank email to standards-+get-1340@lists.php.net to get a copy of this message
From: fabien dot villepinte at gmail dot com Operating system: PHP version: Irrelevant Package: PHP Language Specification Bug Type: Bug Bug description:Inconsistent behavior between constants and magic constants Description: ------------ The functions define(), defined() and constant() don't work the same way whether the name of the constant given as an argument is the name of an already defined constant or the name of a magic constant. For instance : define('PHP_EOL', 0); // returns false and emits a notice define('__DIR__', 0); // returns true __DIR__; // returns the path of the current directory constant('__DIR__'); // returns the value of the user-defined constant, 0 in this case There is nothing in the documentation mentioning this case, so I can't say if the current behavior is correct or not. Test script: --------------- <?php var_dump(defined('__LINE__')); var_dump(define('__LINE__', 'test')); var_dump(constant('__LINE__')); var_dump(__LINE__); Actual result: -------------- bool(false) bool(true) string(4) "test" int(5) -- Edit bug report at https://bugs.php.net/bug.php?id=77100&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77100&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77100&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77100&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77100&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77100&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77100&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77100&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77100&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77100&r=support Expected behavior: https://bugs.php.net/fix.php?id=77100&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77100&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77100&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77100&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77100&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77100&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77100&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77100&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77100&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77100&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77100&r=mysqlcfg

« previous php.standards (#1340) next »