|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-01-20 10:48 UTC] cmb@php.net
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-Package: PHP Language Specification
+Package: Scripting Engine problem
[2020-01-20 10:48 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 10:00:01 2025 UTC |
Description: ------------ When defining a constant of type array from a text file, the (shorter and case sensitive) const command doesn't work, it throws a "Fatal error: Constant expression contains invalid operations in php shell code on line XY" error. The following test script is performed in the command line (php -a) The first command throws: Fatal error: Constant expression contains invalid operations in php shell code on line 1 The second works fine and the third gives the following result: Array ( [0] => Line 1 [1] => Line 2 [2] => Line 3 [3] => ... ) Test script: --------------- const myArrayConst = file("mytextfile.txt", FILE_IGNORE_NEW_LINES); define ("myArrayConst", file("mytextfile.txt", FILE_IGNORE_NEW_LINES)); print_r(myArrayConst);