Bug #73608 [NEW]: inconstistent const behavior

From: Date: Fri, 25 Nov 2016 23:51:56 +0000
Subject: Bug #73608 [NEW]: inconstistent const behavior
Groups: php.standards 
Request: Send a blank email to standards-+get-1189@lists.php.net to get a copy of this message
From: spam2 at rhsoft dot net Operating system: PHP version: 7.0.13 Package: PHP Language Specification Bug Type: Bug Bug description:inconstistent const behavior Description: ------------ why can't you still not use 'const' inside a if-statement? "because it's compile time" is a lie which is easily to realize because otherwise CONST_B could never contain the value of CONST_A which was defined in the if-statement before [harry@srv-rhsoft:/downloads]$ cat test.php <?php $x = 1; if($x == 1) { define('CONST_A', 'A'); } const CONST_B = 'TEST ' . CONST_A; echo CONST_B . "\n"; ?> [harry@srv-rhsoft:/downloads]$ php test.php TEST A -- Edit bug report at https://bugs.php.net/bug.php?id=73608&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73608&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73608&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73608&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73608&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73608&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73608&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73608&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73608&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73608&r=support Expected behavior: https://bugs.php.net/fix.php?id=73608&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73608&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73608&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73608&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73608&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73608&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73608&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73608&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73608&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73608&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73608&r=mysqlcfg

« previous php.standards (#1189) next »