Friday 19 April 2013

PHP Error


PHP Error.
If there is an error in your php script then automatically the error message will appear on your web page and this causes your website looks unprofessional, and error messages that can be seen on the web page you provide loopholes for clicking on hackers hack your website.
We will make a very simple error message with menggukan function die ();.
example:
$ file = fopen ('test.txt', 'r');

if there is no test.txt file on your server may display an error message like this on your web page.
Warning: fopen (welcome.txt) [function.fopen]: failed to open stream:
No such file or directory in C: \ Webfolder \ test.php on line 2
Now we will create an error message that reads "Sorry you mean file not found."
if (! file_exists ('test.txt')) {
die ('Sorry <b> you mean file not found. </ b>');
else {}
$ file = fopen (test.txt'', 'r');
}
So if an error occurs or the file test.txt does not exist then an error message appears aka Sorry you mean file not found.

No comments:

Post a Comment