This tutorial is first tutorial of the basic learning PHP series. Starting from basic elements of PHP and the goal of this tutorial, we can build manageable application. So, this tutorial is intended for everyone beginner in PHP.

PHP’s syntax is derived from many languages, predominantly the C language but Perl has also had a lot of influence on it’s syntax. In the latest object oriented additions, more Java like syntax is creeping in as well.

There are four types of tags available :


standard tags : <?php … ?>

short tags : <? … ?>

script tags : <script language=”php”> … </script>

ASP tags : <% … %>


Standard tags are the de-facto opening and closing tags, they are the best solution for portability and backwards compatibility. They are guaranteed available and can’t be disables by changing PHP’s configuration file. The different tags can be used, only the standard tags is the best practice to always use.

The Short tags have the major drawback of conflicting with XML headers and therefore have somewhat fallen by the wayside. Their other advantage is the availability of the short form “” syntax, which allows we to print the result of an expression directly to the script’s output.

Script tags were introduced so that HTML editors which were able to ignore JavaScript but were unable to cope with the standard PHP tags could also ignore the PHP code. Nobody quite understands why ASP tags were introduced—however,
if we are so inclined we can turn on this optional configuration option, and you are free to use them.

So, we get conclusion of this tutorial, for maximum compatibility, we recommend that we use the standard tags PHP rather than other tags. A PHP scripting block ( with opening and closing tags ) can be placed anywhere in the document. The document or file must have a .php extension, if we use a .hmtl extension, the PHP code will not be executed by server. To complete this tutorial, see following sample php document with standard tags.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • Slashdot
  • Technorati
  • YahooMyWeb