Objective
The PHP script can be placed anywhere in the document. This article mainly includes the following content:
- PHP tags
- Detach from HTML
- Instruction delimiter
- Comments
PHP tags
PHP script to end with:
When parsing a file, PHP looks for the start and end tags, which tells PHP to start and stop parsing the code between the two. This parsing allows PHP to be embedded in a variety of different documents, and any part outside the start and end tags will be ignored by the PHP parser.
PHP also allows the use of short tags , but is discouraged . The short mark can only be used if the Opentag configuration directive in php.ini is activated or if the configuration option –enable-short-tags is used when compiling PHP.
If the file content is pure PHP code, it is best to remove the PHP end tag at the end of the file. This avoids having to accidentally add a space or line break after the PHP end tag, which causes PHP to start outputting these blanks, and there is no intention to output the script at this time.
For example, the following is in a file, this file only PHP code, at this time build justice do not add?> end identity:
"; echo" test
"Echo" www.henishuo.com ";
Detach from HTML
Anything outside a pair of start and end tags is ignored by the PHP parser, which allows the PHP file to have mixed content. You can embed PHP into an HTML document, as shown in the following example:
This isgoingtobeignoredbyphp anddisplayedbythebrowser.
This willalsobeignoredbyphp anddisplayedbythebrowser.
Conditional separation:
This willshowif theexpressionistrue.
Otherwise Thiswillshow.
Instruction delimiter
Like the C language, PHP needs to end the instruction with a semicolon after each statement. An end tag in a PHP code implies a semicolon; the last line in a PHP snippet can end without a semicolon. If there are new rows later, the end tag of the snippet contains the end of the line.
Comments
PHP supports C, C + +, Unix shell style (Perl style) annotations. For example:
You can use//or #注释单行, you can use the/**/comment segment.
Written in the last
This article is only the author to learn PHP notes! Of course, also welcome the master message, to guide the accelerated method. If you feel that they are also useful to you, you are welcome to learn PHP together, discuss PHP grammar knowledge, practice PHP together.
Follow me
PHP Learning Exchange Group: 536643087