Warning: POST Content-Length
how to prevent this dirty warning and provide your own elegant error
So after searching instead of working today I finally got an idea how to solve this, it worked, and even didnt cause much damage. But please first understand what you are doing, before doing it. :) As I suggested in one of my comments it is really possible to turn off PHP errors in .htacess - just turn off the PHP startup warnings.
Before you apply the solution:
Note that: after you insert this code to your .htaccess you won't be able to see any startup error
Also note that: there are more start up errors on line "0" than this one.
Do before: Before you do this you should prepare your script in the way that it should check the uploaded content size and give user a proper information message. The fact that the warning doesnt show DOES NOT mean that you should do nothing about it. It means the EXACT oposite - you should do all that you can to make something at least near-equal to the warning raise - check, double check if you can, handle error and raise your own error message.
Add this to your .htaccess:
php_flag display_startup_errors off
It is not that evil as it seems to be:
Please note that this turns off startup errors only. So all the regular PHP errors/warnings/notices stays ON :)
Even XAMPP's PHP "itself" recommends it for production:
The php.ini file literaly says:
; display_startup_errors ; Default Value: Off ; Development Value: On ; Production Value: Off
PS: "startup error" seems to be those errors before PHP script is executed itself - these errors are usually trying to "persuade" you that they are on the line 0.
Thanks to my idea and this answer: How to disable notice and warning in PHP within .htaccess file?
EDIT: As this is a php_flag setting, you can of course also set it by default in your php.ini if you have custom instalation of PHP :)