Original: Basic grammar-PHP manual notes
PHP tags
If the file content is pure PHP code, it is best to remove the PHP end tag at the end of the file. This avoids having to accidentally add a space or line break after the PHP end tag, which causes PHP to start outputting these blanks , and there is no intention to output the script at this time. Of course, <?php
the space before the start tag of PHP or the line break will still be output.
Advanced separation of conditions of use
The meaning of the following code is very easy to understand, the key is If-else usage, so use in the text output is explicit logic clearer.
<?php $expression = false; ?><?php if ($expression == true): ?>This will show if the expression is true.<?php else: ?>Otherwise this will show.<?php endif; ?>
Instruction delimiter
PHP needs to end the instruction with a semicolon after each statement, and the semicolon is called the instruction delimiter. The last line in a PHP code snippet can end without a semicolon.
Comments
PHP supports c,c++ and Unix shell-style (Perl-style) annotations, i.e. /**/
,, //
#
.
A single-line comment only comments to the end of the line or the current PHP code block, which means that the // ... ?>
# ... ?>
HTML code will be displayed in or after. However, the </script>
tag does not jump out of PHP mode in a single-line comment.
(End of full text)
Basic Syntax-PHP manual notes