Why some php codes include & amp; lt ;? Php but not? & Amp; gt; end? Why some php code has End?
Reply content:
Why some php code has End?
PHP-FIG/PSR-2: Code style Specification
LS writes are good. Let's say a few more words.
A. php:
Is there a blank character?>
B. php:
A. the blank characters at the end of php will also be output, and an error will be reported, and N has not been found for a long time ~~ However?>This problem will not occur.
The lessons of blood and tears
PHP can not use it in a pure PHP file?> End.
This is to avoid errors caused by additional characters when the PHP file is contained.
If the script contains other scripts, what does it end with?> Do not write it to avoid errors.
I have read, the answer does not mention the PSR specification, the basic code specification of the PSR-1, the description of the beginning of the Code and the beginning of the PHP tag is as follows:
-
Overview
The PHP code file must start
2.1. PHP tag
PHP code is required Long tag or Short output tag;
And all the sample code from PSR-1 to 4 is useless?> For reference.
If the file content is pure PHP code, it is best to delete the PHP end mark at the end of the file. This avoids accidental addition of spaces or line breaks after the PHP end mark, which may cause PHP to start to output these spaces, but the script does not have the intention to output at this time.
Echo "Hello world ";
//... More code
Echo "Last statement ";
// The script ends now and no PHP end mark is displayed.
Generally, if a file is at the end of the file to be included, do not use?>End
It is to prevent meaningless output due to white spaces at the end, which affects header output! In addition, the PHP script does not have to end with it.
If there is no other code below PHP, can it be omitted?>
It's all about upstairs.
Pure PHP does not need to be written?>