php does not need to write the ending symbol, because it is mentioned in the zend php specification that if there is only php code in a file, the ending symbol "?>" is not allowed to appear, which is not necessary in php programming , this can avoid accidentally outputting characters such as spaces.
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
php Don’t you need the ending symbol?
First of all, if PHP and HTML are mixed, the PHP code must be written between by default.
For example:
;Secondly, if a PHP file is all PHP code, it does not need to Write the closing symbol, just write the beginning.
Zend's coding specification also mentions this. The general idea is: files containing only PHP code are not allowed to have ?> end symbols to prevent unexpected ending output (such as spaces, newlines ), causing the program to respond unexpectedly.
Generally, this kind of accident occurs when files are included.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Don't you need to write the ending symbol in php?. For more information, please follow other related articles on the PHP Chinese website!