PHP, unlike some other languages, works with the source code being written in the same file as the HTML code. In .NET languages, for example, a .class file distinguishes what will be viewed by the user (HTML) and which is effectively read and interpreted by the server.

However, so there is the correct interpretation of the source code, you must indicate to the server the beginning and the end of the source code so that there is information processing.

When PHP parses a file, it looks for opening and closing tags, which indicate when to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all kinds of documents, as everything outside of a pair of opening and closing tags is ignored by the PHP interpreter.


<p> This will be ignored.</p>
                <?php echo ‘While this will be interpreted.’; ?>
<p> This will also be ignored.</p>

This kind of behavior works as expected, because when PHP hits the parameter “?>” closing tags, it simply starts sending to output anything it finds until you find another opening tag. The example given above is contrived, of course, but is also used to write large blocks of text.

There are two pairs of opening and closing tags that can be used with PHP. As such, “<? Php?>” and “<script language =” php “> </ script>. Any of them can be used at any time. There are still other two are short tags and ASP-style tags, which can be turned on and off from the php.ini configuration file. So, while some people find short tags and ASP style tags in convenient, they are less portable, and generally not recommended.

1.  <?php echo ‘if you want to serve XHTML or XML documents, do like this’; ?>

2.  <script language=”php”>
echo ‘some editors (like FrontPage) do not
they like processing instructions’;

3.  <? echo ‘this is the simplest, an SGML processing instruction’; ?>
<?= expression ?> This is a shortcut for “<? Echo expression ?>”

4.  <% echo ‘You can optionally use ASP-style tags’; %>
<%= $variable; # This is a shortcut for “<% echo . . .” %>

While the tags seen in examples one and two are always available for use, example one is the most commonly used and recommended among them.

While the tags seen in examples one and two are always available for use, example one is the most commonly used and recommended among them

Tags in ASP style (example four) is only available when they are enabled by asp_tags configuration directive in php.ini.

Check out more content on our blog!
Learn all about Scriptcase.

By ,

September 21, 2015


You might also like…

12 IT Trends to Keep an Eye on in 2023

The year 2023 has already started in full swing bringing news and projecting trends for the web dev...

Low-code: it’s the future, not a passing trend

Low-code tools enable professionals to develop fast, efficient, and precise systems. Low-code ha...

What’s new in PHP 8.1

In this article, we will talk a little about the new features, changes, and improvements coming wit...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.