Causes are most often PHP configuration. But it is also possible that the HTTP request was broken or the webserver is misconfigured.
- how to control what is the cause?
You control the configuration with PHP configuration. Same for the webserver. For the broken requests, you need to check if the network is okay, but you can not always control that because normally you don't have control over the whole network. So you can only take care about the part you control.
Best way is to first find out which parts are not affecting this. That means you should first of all exclude that the network is the problem (is the incomming request OK? you can verify that with a network sniffer).
Next step is that you ensure the webserver is working properly. Most webservers assist you with that, check the documentation of the product you use here for your options.
For example if you're using Apache this can be settings like LimitRequestBody or if you've got security modules installed, setting of these modules.
If you're sure that actually PHP is causing the Issue:
As far as the PHP configuration is concerned, the configuration is outlined and documented in the PHP manual. You should start with the
The following options are most often relevant. All need to be set in php.ini
or .htaccess
only (these won't work using ini_set()
):
These are some common culprits but I can not outline all configuration settings that could play a role. Many of these core php.ini directives could apply if you've got broken data. Check especially the HTTP and the Data sections there.
A very important thing is - as you do input processing - that you need to log errors. At the time the data comes to PHP and where it got broken, those errors can only be logged to disk - not displayed. So you need to enable error logging and follow the error log. For the related configuration of PHP Error Handling see a different part in the PHP manual: