PHP provides an error suppressor ' @ ', and how does it prevent error output? When should I use it?
This is the two days some netizens mentioned the common problem, today, simply answer the whole, prepared Yimeimei flip.
How to handle the HTML embedded in PHP files
In PHP, all characters outside the label, in the lexical analysis process, will be translated into t_inline_html token, when parsing, all the t_inlie_html will be assigned Zend_echo output.
Other words:
Copy CodeThe code is as follows:
while ($con) {
?>
Laruence
}
?>
Generates a opline:t_echo, and the operand is "laruence";
As a result, the above code is actually the same as the following result:
Copy CodeThe code is as follows:
while ($con) {
echo "Laruence";
}
?>
But one of the things to note is that for characters outside of the PHP tag, the lexical analysis will be divided in 400 characters, such as:
Copy CodeThe code is as follows:
if (1) {
?>
Laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence LaRue nce laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence L Aruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence Laruen Ce laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence LA Ruence laruence laruence laruence laruence
}
?>
In the above code, there are 531 characters outside the label (including the space carriage return), which will be divided into two t_inline_html output.
Error suppressor
We know that in PHP, you can use the error suppressor to silence the error hint, so what is the way it is?
In the process of parsing, for:
Copy CodeThe code is as follows:
@include (' file ');
?>
Two opline (operations) are inserted before and after the include statement, each of which does the following:
Copy CodeThe code is as follows:
1. Save the current error_reporting value and set error_reporting (0); Turn off error output
2. Restore the previously saved error_reporting value
In other words, the above code, in fact, resembles the following code:
Copy CodeThe code is as follows:
$old = error_reporting (0);
Include (' file ');
Error_reporting ($old);
In addition, say a digression: "When to apply error suppression?", my personal advice is that if this statement goes wrong, you don't care about what the error is, and you don't schedule additional logic to handle the error, then you can use error suppression. Otherwise, please use additional logic to determine the error.
http://www.bkjia.com/PHPjc/323222.html www.bkjia.com true http://www.bkjia.com/PHPjc/323222.html techarticle PHP provides an error suppressor ' @ ', and how does it prevent error output? When should I use it? This is the two days some netizens mentioned common problems, today ...