PHP error handling is easy to say .. It's all here .. I was not found .. Find it. _ PHP Tutorial

Source: Internet
Author: User
PHP error handling is easy to say .. It's all here .. I was not found .. Find it .. One of the common web errors that PHP errors are used to handle is invalid links. Once an invalid link appears from another site, you will reschedule your site. One of the common web errors that people will handle using PHP is invalid links. Once an invalid link appears from another site, you will reschedule your site. People will save their favorite sites as bookmarks. if they visit the site again three months later and only find 404 Not Fount, they will Not be given task help, tell them how to find the original information from your site. Let's solve this problem, or at least give your users a friendly help. once they encounter a 404 error, they will be able to get some marks. You can create common pages to report all errors encountered when processing your pages. PHP and Apache allow you to create your own error page with great freedom, but you need to reconfigure it and compile a small amount of code. Let's first learn about the configuration section. Apache ErrorDocument indicates the document (or URI) to which Apache redirects when an error occurs ). It allows you to specify a resource for the error code that every user may encounter. Add an ErrorDocument 404/error. php directive to your server configuration. This will redirect the user to error. php when accessing a page that does not exist. the error. php page will be written below. Do not forget to restart Apache to make the change take effect. Next, let's write a simple error. php: file you requested ( ) Does not exist on this server. Find the file you want from the front page. Now I try to read a page that does not exist on your server. how can I see error. php? it has a good and friendly message and a link to the previous page. Let's extend it. As you can see, I used the REDIRECT_URL variable in error. php. This variable is set when Apache executes an ErrorDocument directive and provides a possibility to locate the original resource. In this case, Apache also sets some other variables, which can be found here. Using these variables may create a good error page to give users a good and friendly error page, instead of the default page provided by Apache. Output errors from PHP pages output errors from a PHP page and simulate Apache's ErrorDocument directive. you just need to simply redirect users by using the query-string variable, apache is usually set in environment variables. In this way, you can use the same error page to handle various errors. The following is an example :-------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Using the output buffer feature of PHP4 can also help generate common error reports. However, when you confirm that the entire error page has been processed, do not forget to refresh the buffer. you can use Header calls to redirect any part of your code. Readers can design their own error pages to adapt to their/her websites. Don't forget, you can include an email submission form on the error page, so that users can give you some feedback.

One of the common web errors of Ingress is invalid links. Once an invalid link appears from another site, you will reschedule your site. People will...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.