Using the functions die () and exit () in PHP
die() and Exit() has a similar method of displaying error strings so that when you get an error you can be sure that you are generating your own text. This has to use every string or else it is useless.
The two functions are different from set_error_handler () because they rely on their own text without text from the system. But in this function it uses text from the direct system and its advantages can recognize all strings. But that is not a problem, as both functions can be used with the help of other functions.
In this article we are going to tell you how to use the feature die() and Exit() with the help of simple functions such as: if else, fopen, or and file_exist. See below.!
File does not exist
Above I want to provide a tutorial to solve the file that doesn’t exist. For example, the above function is very clear fopen Call file read.txt in the directory, but the file does not exist and such an error is displayed as a result.!
Warnings: fopen (read.txt) [function.fopen]: Stream could not be opened: No such file or directory in /home/public_html/anu/testing.php on-line 2
And to get around this, you can use the die or exit functions, including calling Strings, for example as follows.
With the code above using the help function or can display error messages from function die(). function die above can be replaced by exitbecause it’s the same. Then it can also be used with the if else function and that’s even easier and, in my opinion, better. Please refer to the code below.!
So the above code doesn’t ask for fopen, but uses file_exist so that if the file is found, it can be called directly with fopen.
The examples for all of the above code use the function, but it can also be confirmed to be the same function as the Exit function. It is better to use this method because it can display the error message without the system recognizing and entering the error logs.
To practice each of the above codes, please copy and paste directly to avoid syntax errors: D.
Hopefully useful and good luck