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.

Example:

<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’;
</script>

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

a

You might also like…

5 reasons you can’t miss a Black Friday Scriptcase!

This November we bring you the biggest and most important discounts of the year! And do you know wh...

Taking a look at Scriptcase version 9.7

After the big Scriptcase 9.7 presentation event, we have a new version of Scriptcase for download, ...

October Newsletter

Follow the latest news for the month of October! Webinars, blog posts, videos, and more. WEB...

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 sales@scriptcase.net. Learn more about our Privacy Police.