1.11. Understanding PHP Error Messages

PHP tries to be helpful when problems arise. It provides different types of error messages and warnings with as much information as possible.

1.11.1. Types of PHP error messages

PHP can display five types of messages. Each type of message displays the name of the file where the error was encountered and the line number where PHP encountered the problem. Different error types provide additional information in the error message. The types of messages are

  • Parse error: A parse error is a syntax error that PHP finds when it scans the script before executing it.

  • Fatal error: PHP has encountered a serious error that stops the execution of the script.

  • Warning: PHP sees a problem, but the problem isn't serious enough to prevent the script from running.

  • Notice: PHP sees a condition that might be an error or might be perfectly okay.

  • Strict: Strict messages, added in PHP 5, warn about coding standards. You get strict messages when you use language that is poor coding practice or has been replaced by better code.

We recommend writing your PHP scripts with an editor that uses line numbers. If your editor doesn't let you specify which line you want to go to, you have to count the lines manually from the top of the file every time that you receive an error message. You can find information about many editors, including descriptions and reviews, at www.php-editors.com ...

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.