Bug #69913 [NEW]: arrays are allowed in 'const' but not 'define'

From: Date: Tue, 23 Jun 2015 16:04:44 +0000
Subject: Bug #69913 [NEW]: arrays are allowed in 'const' but not 'define'
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193809@lists.php.net to get a copy of this message
From: gordon dot mcvey at ntlworld dot com Operating system: OSX 10.10.3 PHP version: 5.6.10 Package: PDO Core Bug Type: Bug Bug description:arrays are allowed in 'const' but not 'define' Description: ------------ ./php -v PHP 5.6.9 (cli) (built: May 15 2015 13:05:42) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans You can define an array in PHP 5.6 on a constant if you use const. However, you can't if you use define. This seems like inconsistent behaviour. Test script: --------------- <?php const A = [1,2,3]; var_dump (A); define ("B", [4,5,6]); var_dump (B); Expected result: ---------------- array(3) { [0] => int(1) [1] => int(2) [2] => int(3) } array(3) { [0] => int(4) [1] => int(5) [2] => int(6) } Actual result: -------------- array(3) { [0] => int(1) [1] => int(2) [2] => int(3) } PHP Warning: Constants may only evaluate to scalar values in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 PHP 2. define() php shell code:1 PHP Notice: Use of undefined constant B - assumed 'B' in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 string(1) "B" -- Edit bug report at https://bugs.php.net/bug.php?id=69913&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69913&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69913&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69913&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69913&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69913&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69913&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69913&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69913&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69913&r=support Expected behavior: https://bugs.php.net/fix.php?id=69913&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69913&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69913&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69913&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69913&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69913&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69913&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69913&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69913&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69913&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69913&r=mysqlcfg

« previous php.bugs (#193809) next »