Basic Error Handling: Using the die Function
The first example shows a simple script that opens a text file. If the file does not exist, an error occurs. |
|
To avoid that the user gets an error message like the one above, we test if the file exists before we try to access it.
The example uses a simple error handling mechanism to stop the script after the error by using the PHP functions:
|
|