" is not allowed to appear. This is not necessary in PHP programming, so as to avoid accidental output. White space and other characters."/> " is not allowed to appear. This is not necessary in PHP programming, so as to avoid accidental output. White space and other characters.">

Home  >  Article  >  Backend Development  >  Don’t you need to write the ending symbol in php?

Don’t you need to write the ending symbol in php?

藏色散人
藏色散人Original
2022-11-04 10:58:371962browse

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.

Don’t you need to write the ending symbol in php?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn