php command separator

怪我咯
Release: 2023-03-10 15:34:02
Original
2543 people have browsed it

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" ;
?>
Copy after login
<?php  echo  "This is a test"  ?>
Copy after login
<?php  echo  &#39;We omitted the last closing tag&#39; ;
Copy after login

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";
?>
Copy after login
<?php echo "This is a test"?>
Copy after login

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
?>
Copy after login

"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;.
Copy after login

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*/
*/
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!