Home  >  Article  >  Backend Development  >  Basic Syntax - PHP Manual Notes

Basic Syntax - PHP Manual Notes

WBOY
WBOYOriginal
2016-08-08 09:29:331025browse

PHP tag

If the file content is pure PHP code, it is best to remove the PHP closing tag at the end of the file. This prevents PHP from accidentally adding spaces or newlines after the closing tag, causing PHP to start outputting these spaces when there is no intention to output them in the script. Of course, the space or newline character before the PHP start tag <?php will still be output.

Advanced separation using conditions

The meaning of the code below is easy to understand. The key is the usage of if-else, which makes the logic clearer when used in text output.

<?php $expression = false; ?>
<?php if ($expression == true): ?>
This will show if the expression is true.
<?php else: ?>
Otherwise this will show.
<?php endif; ?>

Command separator

PHP needs to end the command with a semicolon after each statement. This semicolon is called the command delimiter. The last line in a PHP snippet does not need to end with a semicolon.

Notes

PHP supports C, C++ and Unix Shell style (Perl style) comments, namely /**/, //, #.

Single-line comments only comment to the end of the line or the current PHP code block, which means the HTML code after // ... ?> or # ... ?> will be displayed. However, the </script> tag will not break out of PHP mode in single-line comments.

(Full text ends)

The above introduces the basic syntax - PHP manual notes, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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