How It Works (Web design rates) The output that you see

How It Works The output that you see in the browser will be the same as you saw before, but behind the scenes, the mail() function is used to send an e-mail to the administrator. Some other PHP functions, such as getdate(), are used to note the time and day the error occurred. The mail() function allows you to e-mail anyone you desire when an error occurs. You will learn about the mail() function in more detail in Chapter 11. Also, by using getdate(), you are able to retrieve when exactly the error occurred so you can make note of the error s time of occurrence. You can get the date in many ways, including the date() function, but the getdate() function is a little easier to decipher. We threw in some function practice for you to get the hang of sending variables as parameters to and from functions. Now the administrator or Webmaster will be getting an HTML-formatted e-mail concerning the error message that the user received when he or she happened to go to that page. That s it! You just used Apache s ErrorDocument directive to help you maintain your server. Error Handling and Creating Error Handling Pages with PHP This section looks at how you can troubleshoot your PHP scripts using simple logical steps. First, however, you need to understand what PHP does when it encounters an error and what it does with certain errors. When a PHP script gets executed and encounters an error, it displays a message in the browser showing you what the error was. Depending on what type of error occurred, the script may not finish executing. You are likely to run into these sorts of errors when writing your own scripts. Don t feel ashamed if you receive errors; everybody makes errors when writing code, no matter what your level of expertise. Even though it is normal to receive errors during the development of your script, you don t want errors (which are normally complicated for the layperson to understand) popping up to end users when your site has gone live. For this reason, it s important to know how to catch those unwanted errors and generate more user-friendly errors that let the user know that there will be a solution forthcoming. Error Types in PHP There are 12 types of errors in PHP, which are listed in the following table, along with the Report All Errors option. Each of these can be called by either an integer value or a named constant. Slight changes have been made as of PHP5: the addition of E_STRICT, and that E_ALL does not include E_STRICT. Error Integer Value NAMED CONSTANT E_ERROR 1 Fatal runtime error. E_WARNING 2 Non-fatal runtime error. E_PARSE 4 Compile-time parse error. E_NOTICE 8 Non-fatal runtime notice. E_CORE_ERROR 16 Fatal error occurring at startup. 260 Chapter 9
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply