O'Reilly logo

PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition by Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Logging PHP Errors

In the previous example, errors were handled by simply printing them out in detail or not. Another option is to log the errors: make a permanent note of them somehow. For this purpose, the error_log() function instructs PHP how to file an error.

error_log (message, type, destination,
→ extra headers);

The message value should be the text of the logged error. The type dictates how the error is logged. Table 6.2 lists the types of error logging you can use. The destination parameter can be either the name of a file (for log type 3) or an email address (for log type 1). The extra headers argument is used only when sending emails (log type 1). Both the destination and extra headers are optional.

Table 6.2. PHP can log errors ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required