Bug #76294 [NEW]: Variable expansion taking place into string when using undefined constant.

From: Date: Wed, 02 May 2018 10:54:15 +0000
Subject: Bug #76294 [NEW]: Variable expansion taking place into string when using undefined constant.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215004@lists.php.net to get a copy of this message
From: dpastor at comvive dot es Operating system: Ubuntu Linux 64 PHP version: 7.2Git-2018-05-02 (Git) Package: *General Issues Bug Type: Bug Bug description:Variable expansion taking place into string when using undefined constant. Description: ------------ Code using array string indexes without quotes is interpreted in newer versions of PHP as undefined constants. However, the same behaviour is not observed when variable expansion takes place. See the example code. Test script: --------------- <?php $friends="friends"; $countries['mexico']="land of the good people"; //echo $countries[mexico] will result in a warning. //This, however, results in the correct expansion. $greet="Hi $friends, welcome to $countries[mexico]"; echo $greet; Expected result: ---------------- Unless I am mistaken, I expect the parser to be consistent and tell me that $countries[mexico] is trying to reference an undefined constant when using it inside variable expansion (as it does outside of it). -- Edit bug report at https://bugs.php.net/bug.php?id=76294&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76294&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76294&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76294&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76294&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76294&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76294&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76294&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76294&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76294&r=support Expected behavior: https://bugs.php.net/fix.php?id=76294&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76294&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76294&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76294&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76294&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76294&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76294&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76294&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76294&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76294&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76294&r=mysqlcfg

« previous php.bugs (#215004) next »