First, PHP tags
When parsing a file, PHP will look for the start and end tags , i.e. <?php , and the ?> part outside the tag will be ignored by the parser.
Attention
The start tag must be followed by a white space character, or an error will occur.
Ii. separating from HTML
Anything outside of the PHP start and end tags will be ignored by the PHP parser. The exception is when you use a control statement:
<?php$expression =TRUE;?><?phpIf($expression = =True?> this would show if The expression is true. <? PHP else: ?> Otherwise this would show. <? PHP endif?><!--output is: This'll show if the expression is true.-->
C. Instruction delimiter separation
Use semicolons to separate statements, and the semicolon of the last statement can be omitted.
Iv. notes
There are 3 types of PHP Comments:
// 单行注释# 单行注释/* 多行注释*/
-
The contents of a multiline comment start with/* and end with the/*, so that multiline comments cannot be nested.
-
The content of a single-line comment starts with a//or #, ends at the end of the line, or encounters?> to exit PHP parsing prematurely. Sometimes this can cause some problems:
<?Php$file _contents =' <?php die ();?> ';?> <!--correctly string ' ' <?php die ();?> " Assignment to ' $file _contents<? PHP //$file-contents = ' <?php die (); ?> " Span class= "Hljs-meta" >?> <!--php to the first ' ?> ' on exit parsing, followed by ' ' ; ?> ' part of HTML--
php-Basic Syntax