Home > Article > Backend Development > php command separator
Like C or Perl, PHP requires a semicolon to end the directive after each statement. The closing tag in a PHP code section implicitly represents a semicolon; the last line in a PHP code section may not end with a semicolon. If a newline follows, the end of the line is included in the snippet's closing tag.
<?php echo "This is a test" ; ?>
<?php echo "This is a test" ?>
<?php echo 'We omitted the last closing tag' ;
The PHP code segment end tag at the end of the file is not required. In some cases, it is better to omit it when using include or require, so that there is an unexpected white space. character will not appear at the end of the file, and response headers can still be output later. It is also convenient when using output buffering, so that you will not see unexpected whitespace characters generated by include files.
The bundle marker (?>) also implies the end of the statement, so the following code is equivalent
<?php echo "This is a text"; ?>
<?php echo "This is a test"?>
php supports 'c', c++ and unix shell style comments; for example:
<?php echo "This is a test";//This is a one-line c++ style comment /*This is a multi line comment yet another line of comment*/ echo "This is yet another test"; echo "One Final Test";#This is shell-style style comment ?>
"Single line" comments only comment to the end of the line or the current block of code, whichever comes first.
<h1>This is an <?php # echo "simple"?>example.</h1> <p>The header above will say 'This is an example'.
Be careful not to nest 'C' style comments, you can make this mistake when commenting large amounts of code.
<?php /* echo "This is a test";/*This comment will cause a problem*/ */ ?>
Single-line comments only comment to the end of the line or the current php codeblock
The above is the detailed content of php command separator. For more information, please follow other related articles on the PHP Chinese website!