1

In production I don't want to show the following error:

<b>Warning</b>:  POST Content-Length of 25633071 bytes exceeds the limit of 20971520 bytes in <b>Unknown</b> on line <b>0</b><br />

error_reporting is set to 0...

error_reporting(0);

But I'm still getting the error. How can I suppress this error so I can display my own error page?

The error messages are handled by exceptions

Hemerson Varela
  • 24,034
  • 16
  • 68
  • 69
clarkk
  • 27,151
  • 72
  • 200
  • 340
  • check the value of `ini_get('error_reporting')` to make sure it is actually set – km6zla May 24 '13 at 16:22
  • 1
    turn error reporting off in php.ini rather than in the script. – τεκ May 24 '13 at 16:23
  • `ini_get('error_reporting')` returns `32767`... I want to hide the error and instead throw my own errors – clarkk May 24 '13 at 16:24
  • @WesleyMurch of course you can fix it. It's a setting controlled in php.ini... http://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size – Patrick Moore May 24 '13 at 16:26
  • @SetSailMedia It's very often not an option to edit php.ini, and even then it's not always a good idea to remove the limit. Your link merely speaks to increasing the limit. In order to never have this error occur you'd have to remove it entirely. – Wesley Murch May 24 '13 at 16:27
  • I think, this error appear before the script is executed, because the file is passed to the script by your web server. Can you try set error_reporting directly in your php.ini config file? Also check: post_max_size, upload_max_filesize, memory_limit. – moechofe May 24 '13 at 16:30

2 Answers2

3

ini_set('error_reporting') doesn't work in this case because the error happens before the script is executed.

So you have to set it in php.ini.

But don't disable error reporting, errors can be very useful for you.

Hiding them from your users is enough (and recommended). You can do it by setting display_errors to 0 in php.ini. Then enable log_errors.

Arnaud Le Blanc
  • 98,321
  • 23
  • 206
  • 194
0

Using the tilde will stop errors of a certain type - This directive worked for me to stop showing warnings:

(line 514 of php.ini) error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE

inorganik
  • 24,255
  • 17
  • 90
  • 114