"; 2. Short style, syntax "...?>"; 3. ASP style, syntax "<%... %>"; 4. SCRIPT style, syntax ""."/> "; 2. Short style, syntax "...?>"; 3. ASP style, syntax "<%... %>"; 4. SCRIPT style, syntax "".">
Home >Backend Development >PHP Problem >There are several styles of php markup
There are 4 styles: 1. XML style, syntax "5208e2eec18b61aba7fec17a45ba6d05"; 2. Short style, syntax "89873dac446404b3fe33cc3be13f7626"; 3. ASP style, syntax "9613d184b92a8db8e14f8dcd66cf91f2"; 4. SCRIPT style, syntax "842e8e9dd470ac0da5d8b75be3525bf2...2cacc6d41bbb37262a98f745aa00fbf0".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The so-called tags are for the purpose of distinguishing them from other content. A special symbol used (e.g. a8df170e0ef276d99f0be5daf8568fc0). In PHP, when parsing a .php format file, PHP looks for opening and closing tags, and any text between these two tags will be interpreted as PHP code. Any text outside the tag will be considered regular HTML, which means that PHP tags can play a role in isolating PHP code and HTML.
There are four markup styles in PHP, and I will introduce them one by one below.
1. XML style
<?php echo "PHP中文网"; ?>
This is the most commonly used markup style, and it is also the markup style recommended by PHP.
This style is enabled by default and cannot be disabled, so it is guaranteed that this style of markup can be used on all servers, especially when writing some applications for different server environments. Markup style is especially important.
2. Short style
<? echo "PHP中文网"; ?>
This tag style is the simplest. To use this tag style, you need to enable the short_open_tag option in the configuration file php.ini . However, it is not recommended to use this style of markup in daily development, because this style of markup is no longer supported in the default settings of many environments.
3. ASP style (removed)
<% echo "PHP中文网"; %>
This markup style is the same as the markup style of ASP or ASP.NET. By default, this style is Disabled. To use it you need to enable the asp_tags option in the configuration settings.
However, this markup style is no longer supported in PHP7, just understand it.
4. SCRIPT style (removed)
<script language="php"> echo 'PHP中文网'; </script>
This markup style is the longest. If readers have used JavaScript or VBScript, they will be familiar with this style. style.
This markup style is no longer supported in PHP7, just understand it.
Note: If the file content is pure PHP code, it is best to omit the PHP closing tag at the end of the file. This can avoid accidental insertion of spaces or newlines after the PHP end tag, which will lead to unexpected spaces and newlines in the output results.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of There are several styles of php markup. For more information, please follow other related articles on the PHP Chinese website!