Hi,
If I have a link to a file that does not exist and the user clicks it, the following message will appear:
Warning: main(pages/script.php) [function.main]: failed to open stream: No such file or directory in /home/site/public_html/index.php on line 163
How can I display a friendlier message or redirect the user instead of having this techy message appear?
Thanks
override PHP warning page
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- Gente
- Forum Contributor
- Posts: 252
- Joined: Wed Jun 13, 2007 9:43 am
- Location: Ukraine, Kharkov
- Contact:
set_error_handler()
http://www.php.net/manual/en/function.s ... andler.php
http://www.php.net/manual/en/function.s ... andler.php
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Simplest way possible:
Always always always check for possible errors and catch them when you possibly can.
Code: Select all
<?php
if (!file_exists($filename))
{
echo 'This is my own custom error message, made just by yours truly.';
// Maybe even exit at this point, if you want to prevent further processing.
}
else
{
// carry on.
}
?>