I am getting expected notices and warnings and would like to turn them off in my PHP file. The error is:
Warning: fsockopen()
And the notice are:
Notice: A non well formed numeric value encountered in
I am planning to use cron for this PHP script and do not want to get any errors or notices logged anywhere.
When you are sure your script is perfectly working, you can get rid of warning and notices like this: Put this line at the beginning of your PHP script:
Before that, when working on your script, I would advise you to properly debug your script so that all notice or warning disappear one by one.
So you should first set it as verbose as possible with:
UPDATE: how to log errors instead of displaying them
As suggested in the comments, the better solution is to log errors into a file so only the PHP developer sees the error messages, not the users.
A possible implementation is via the .htaccess file, useful if you don’t have access to the php.ini file (source).