PHP Tags
suggest changeThere are three kinds of tags to denote PHP blocks in a file. The PHP parser is looking for the opening and (if present) closing tags to delimit the code to interpret.
Standard Tags
These tags are the standard method to embed PHP code in a file.
<?php
echo "Hello World";
?>
Echo Tags
These tags are available in all PHP versions, and since PHP 5.4 are always enabled. In previous versions, echo tags could only be enabled in conjunction with short tags.
<?= "Hello World" ?>
Short Tags
You can disable or enable these tags with the option short_open_tag
.
<?
echo "Hello World";
?>
Short tags:
- are disallowed in all major PHP coding standards
- are discouraged in the official documentation
- are disabled by default in most distributions
- interfere with inline XML’s processing instructions
- are not accepted in code submissions by most open source projects
ASP Tags
By enabling the asp_tags
option, ASP-style tags can be used.
<%
echo "Hello World";
%>
These are an historic quirk and should never be used. They were removed in PHP 7.0.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents