|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-02-23 22:32 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2016-02-23 22:32 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 20:00:01 2025 UTC |
Description: ------------ The test script creates a class containing a large static array initialization like : class MyClass { public static $arr = array('a0'=>1,'a1'=>1,'a2'=>1,etc. } Then, running the created test script shows that the created array is smaller than the expected array. If the number of entries in this array is larger than 32768 (0x8000), then the lower 32768 entries are lost. So, for example the a0 to a32768 entries are not in the array, and the a32769... entries are in the array. PHP was compiled with : ./configure --prefix=/usr/local/phpTest make make install Test script: --------------- <?php $numberOfEntries = $argv[1]; // Use for example '35000'. $code = "<?php\n"; $code .= "class MyClass {\n"; $code .= " public static \$arr = array(\n"; for ($i = 0 ; $i < $numberOfEntries ; $i++) { if ($i != 0) { $code .= ","; } $code .= "'a$i'=>1"; } $code .= " );\n"; $code .= "}\n"; $code .= "print \"Number of entries in the array: \".count(MyClass::\$arr).\"\\n\";\n"; $code .= "?>\n"; file_put_contents('./myclass.php', $code); /* Then run in a shell: php bug.php 35000 # This creates the myclass.php file. php myclass.php # This shows the number of entries in the array. > Number of entries in the array: 2232 <- it should say 35000 instead. Note: 35000-2232 = 32768 = 0x8000. So, this is the proof that the array is truncated, and lost its first 0x8000 entries. */ ?> Expected result: ---------------- After running: php bug.php 35000 The second script is run: php myclass.php This second script should display: Number of entries in the array: 35000 However, it displays: Number of entries in the array: 2232 Note: 35000-2232 = 32768 = 0x8000.