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.

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.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

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