|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-23 16:06 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Package: PDO Core
+Package: Scripting Engine problem
-Assigned To:
+Assigned To: nikic
[2015-06-23 16:06 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 06:00:01 2026 UTC |
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"