Home  >  Article  >  Backend Development  >  php command separator

php command separator

怪我咯
怪我咯Original
2017-06-16 15:58:562598browse

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  &#39;We omitted the last closing tag&#39; ;

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"?>

Comments:

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 &#39;This is an example&#39;.

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!

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