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.

interpretation of php files

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.

You might also like…

Scriptcase uses the MVC template?

Maybe you might have thought about this at some point, “Scriptcase uses the MVC templates?" Well, ...

How to implement A2F using Own Development in NodeJS in a Scriptcase application

A2F using Own Development in NodeJS A2F: In a previous article, we talked about Swivel as an extern...

Specialists or generalists, who gets a better advantage by using Scriptcase?

Hey there! Today  we will figure what are the ideal profiles for those who wish to take advantage o...

Comment this post

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.