I personally verified that the capacity of phpsession and array is controlled by the memory size configured in php. after a function is completed today, many arrays are used, so I am eager to figure out the size of the php array and session, in fact, I mainly want to verify that the size of the array I heard is related to configuration. I personally verify that the size of the php session and array is controlled by the size of the memory configured in php.
After completing a function today, I used a large number of arrays, so I was eager to figure out the size of the php array and session, in fact, I mainly want to verify that the array capacity I have heard is correct with the configuration.
Array verification code program:
$ Arr = array (); // This line can be omitted. I prefer to follow the principle of first declaration and then use in java.
For ($ I = 0; I I <8000000; $ I ++ ){
$ Arr [$ I] = $ I;
}
Echo count ($ arr );
Unset ($ arr );
Session verification code program:
Ession_start ();
For ($ I = 0; I I <8000000; $ I ++ ){
$ _ SESSION [$ I] = $ I;
}
Echo count ($ _ SESSION );
After running the above program, the following error message is displayed:
Note: in php. ini, the memory_limit value is 10 MB.
Then, my verification method is to set php. in ini, the value of memory_limit is changed to 1000 M. then, restart apache and run the verification program again. then, the value of array and session can be normally output.
Isn't it because I modified php. ini? is it because of other coincidences? I want to verify again if it is php. in ini, memory_limit is configured. I reset the value to 10 M, restart apache, and run the verification program again. The result is indeed an exception in memory insufficiency. Now I believe that the size of array and session is indeed related to the memory_limit configuration in php. ini.
However, the maximum size of this value is 1300 MB. after the verification program is run, my computer is almost dormant:
The above is only my personal verification point of view and is only for sharing and use. the verification method must be insufficient. thank you for your guidance.