Home  >  Article  >  Backend Development  >  A summary of the "limitations" often touched on in php.ini

A summary of the "limitations" often touched on in php.ini

WBOY
WBOYOriginal
2016-08-08 09:29:531321browse

max_execution_time
PHP maximum execution time, the default value in php.ini is 30, that is, after the page is executed for 30 seconds, the server will directly forcibly terminate the execution of the page.

For general pages, 30s is enough, but for some pages that require direct use of PHP execution for large amounts of data analysis, you need to adjust the value of max_execution_time based on the efficiency of page execution, and of course improve your algorithm as much as possible to get the best results. Optimal page execution efficiency.
max_input_vars
The maximum number of submitted forms (controls) in php. The default value in php.ini is 1000, that is, the number of controls (inputs) contained in a form form post data cannot exceed 1000.

1000 inputs are not enough? Can people fill it in? You may have such questions, but I did encounter such a problem during the actual programming process: upload an excel table document, use the PHPExcel class library to parse it, and then output it to a page for the user to confirm. After confirmation, press " "Submit data" is inserted into the database. Each unit of data is stored in form-input (hidden). The number of inputs is 200 (rows) * 8 (columns) = 1600, which exceeds the default number. As a result, the first one is inserted into the database each time. 125 pieces of data.

When I first encountered this problem, I directly output the value of $_POST on the page and found that there were only 125 records. It was determined that it was a problem with the post transmission. I found a few similar problem information on the Internet, which basically focused on PHP's post size limit. However, in php.ini I found that the default value of post_max_size is 32M, and the amount of data in a post form will not exceed 32M anyway. I don’t think the problem is the post size limit. I later realized that it might be a restriction on the control, and finally found that max_input_vars was a restriction on the post control. However, I can't find the relevant information about max_input_vars in the php.ini of wamp installed on my local machine, so I can only add it myself.

<code><span>; Maximum input variable nesting level</span><span>; http://php.net/max-input-nesting-level</span><span>;max_input_nesting_level = 64</span><span>max_input_vars = <span><span>5000</span>;   //默认<span>1000</span></span></span><span>; Maximum amount of memory a script may consume (128MB)</span><span>; http://php.net/memory-limit</span><span>memory_limit = <span><span>128</span>M</span></span></code>


upload_max_filesize and post_max_size
One is the maximum limit for uploading files, and the other is the maximum limit for posts.

When you need to use php post to upload large files, remember to change them (maximum file value <= upload_max_filesize <= post_max_size), otherwise the file will fail to upload or only a part of the file will be uploaded (for example: upload a 20M file test.zip , upload_max_filesize is only 10M, and what is uploaded to the server is most likely a 10M test.zip)
max_input_time
This variable limits the time in seconds for receiving data through post and get methods. The default value is 60, which is 60s.

If your application is running on a slow link, you can increase this value to accommodate the additional time required to receive data.

The above has introduced a summary of the "restrictions" that are often touched in php.ini, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn