Home >Backend Development >PHP Tutorial >http://www.12306.cn/mormhweb/k In-depth understanding of PHP principles, error suppression and embedded HTML analysis
PHP provides an error suppressor '@'. How does it prevent error output? When should I use it?
This is a common problem mentioned by some netizens in the past two days. Today I will simply summarize it. Answer for future reference.
How to handle embedded HTML in PHP files
In PHP, all characters outside the tags will be translated into T_INLINE_HTML tokens during the lexical analysis process. During the syntax analysis, all T_INLIE_HTML will be assigned ZEND_ECHO output.
That is to say:
Copy the code The code is as follows:
while($con) {
?>
laruence
}
?>
Copy the code The code is as follows:
while($con) {
echo "laruence";
}
?>
Copy the code The code is as follows:
if(1) {
?>
laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence laruence
}
?>
Copy the code The code is as follows:
@ include('file');
?>
Copy the code The 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
Copy the code The code is as follows:
$old = error_reporting(0);
include('file');
error_reporting($old);
The above has introduced the http://www.12306.cn/mormhweb/k in-depth understanding of PHP principles, error suppression and embedded HTML analysis, including the content of http://www.12306.cn/mormhweb/k. I hope Helpful for those who are interested in PHP tutorials.