When PHP parses a file, it looks for opening and closing tags, which are
?> which tell PHP to start and stop interpreting the code between them.
PHP also allows for short tags
?>, which are discouraged because they are not always available.
Everything outside of a pair of opening and closing tags is ignored by the PHP parser which allows PHP files to have mixed content. This allows PHP to be embedded in HTML documents, for example to create templates.
There are four different pairs of opening and closing tags which can be used in PHP:
- Always available:
<?php ... ?>
<script language="php"> ... </script>
- Can be turned on and off from the php.ini configuration file:
<? ... ?>: short tags.
<% ... %>: ASP style tags.
; at the end of each statement.
//: One line comment.
#: One line comment.
/* */: Block comment, it is an error to nest these comments.