CHAPTER 7 – TYPES OF ERRORS – Runtime Errors
Once code is up and running, non-fatal runtime errors are the most common type of error in PHP. Runtime refers to errors that occur during execution of the code, which are not usually programming errors but caused factors outside PHP itself, such as disk or network operations or database calls. PHP has an error-reporting mechanism that is used for all errors trig- gered inside PHP itself, either during compilation of the script or when execut- ing a built-in function. You can use this error-reporting mechanism from a script as well, although there are more powerful ways of reporting errors (such as exceptions). The rest of this chapter focuses on some forms of runtime errors. Even perfectly good code may produce runtime errors, so everyone has to deal with them in one way or another. Examples of runtime errors occur when fopen() fails because a file is miss- ing, when mysql_connect() fails because you specified the wrong username, if fsockopen() fails because your system runs out of file descriptors, or if you tried inserting a row into a table without providing a required not-null column.