Home >Backend Development >PHP Tutorial >Program to customize the 404 error page and send a letter to the administrator
If your user cannot find the page he is looking for, how to give him a friendly reply, and you also know that this error has occurred? Take a look at the following program, which is used to customize the 404 error page and send a notification to the network administrator. nice one. ---teaman translation and finishing
# Set $domain as your domain name (note that there is no www)
$domain = "oso.com.cn";
# Set the URL, note that there is no trailing /
$ docroot = "http://www.oso.com.cn";
# Set the font of the error message
$fontface = "Verdana";
# Set the font size of the 404 page
$fontsize = "2";
# Set The background color of the 404 page, the default is white
$bgcolor = "#ffffff";
# Set the text color, the default is black
$textcolor = "#000000";
# Use the $reportlevel variable to control whether to send the message to Network management
# 0 = No need to send a message at all, hey, how could teaman go wrong?
# 1 = Only send a message when the page contains your DOMAIN NAME
# 2 = Send a message even if the connection to me is disconnected, It may be a friendly site
$reportlevel = 2; //This is the safest option
$emailaddress = "webmaster@oso.com.cn"; //Set the email address to receive error messages
function print_details()
{
# Request access to the global variables we need
global $fontface, $fontsize, $docroot, $REQUEST_URI, $reportlevel;
global $bgcolor, $textcolor;
# Print the 404 error in web format
echo "< head>
echo "Oso Network Administrator reminds you that the page you requested, $docroot$REQUEST_URI, doesn't exist";
echo " on this server.