I post this thread, because it is useful, and it is very basic php, so no credits belongs to it.
Here is the idea:
Users (you, everybody who enters the site and surf around) might encounter php errors, however, you might want to keep your errors to yourself for security reasons.
So I found a handy php script, every time a error message occurs, it does NOT get displayed on the website, instead, it gets logged inside a text document. In some cases, the person who surf won't notice any thing at all.
The new PHP which many use, PHP 5.3~ tend to be more sensitive, so recently many errors have occur which really ain't such a big deal.
It is VERY easy to use, locate your Index.php or root php document, and paste this:
At the top of index.php.
OR:
Here is an example of how it may look:
Then create a file named error.txt in same dir as index.php and you're good to go.
Here is the idea:
Users (you, everybody who enters the site and surf around) might encounter php errors, however, you might want to keep your errors to yourself for security reasons.
So I found a handy php script, every time a error message occurs, it does NOT get displayed on the website, instead, it gets logged inside a text document. In some cases, the person who surf won't notice any thing at all.
The new PHP which many use, PHP 5.3~ tend to be more sensitive, so recently many errors have occur which really ain't such a big deal.
It is VERY easy to use, locate your Index.php or root php document, and paste this:
PHP:
<?php
ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'Off');
ini_set('log_errors', 'On');
ini_set('error_log', 'error.txt');
?>
At the top of index.php.
OR:
PHP:<?php ini_set('error_reporting', E_ALL | E_STRICT); ini_set('display_errors', 'Off'); ini_set('log_errors', 'on'); ini_set('error_log', 'error.txt'); if(filesize('error.txt') > 10485760) ini_set('log_errors', 'off'); ?>
This is a safe version. Allowing only 10MB log.
Here is an example of how it may look:
Then create a file named error.txt in same dir as index.php and you're good to go.
Last edited: