note 113891 deleted from function.error-reporting by sobak
| From: | sobak@php.net | Date: | Fri, 25 Nov 2016 08:56:45 +0000 |
| Subject: | note 113891 deleted from function.error-reporting by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207689@lists.php.net to get a copy of this message | ||
Note Submitter: polecat1
----
Most of you know that a script can give different results online compared to your local machine (PHP
versions, settings). Nobody wants to see an error message on your online website, like "Access
denied for user 'YOURUSERNAME'@'localhost' (using password: YOURPASSWORD)".
But sometimes we do need this information on our online site for debugging. Here's a little
trick.
On your local machine for your own browser create a cookie, something like:
setcookie ("your-website.com-testing", "1", time()+60*60*24*300);
Then in all your pages (or in includes) add the following line:
if (!isset($_COOKIE["your-website.com-testing"])) {
error_reporting(0);
}
This way errors will be reported ONLY when the page is displayed in YOUR browser.