PHP syntax tags

the php is run on the server side and the plain html code is sent back to the browser.


standard PHP syntax

a complete php files can contain text, html, css, javascript and php code.

php files have extension ".php"

a standard php script starts with <?php and ends with ?>, it can be set anywhere in the php file.

syntax:

         <?php

                  //php code put here 

        ?>

php statements are terminated by semicolon(;).

  <html>
  
      <head>  <title> standard php tags </title>
      
      </head>
      
    <body>
    
        <p> this is html document p tag </p>
        
    <?php   
           
        echo "<p>this is the php  echo function, to output on  web page</p>" ;
                   
        echo "this is another echo statement" ;
        
    ?>
</body>

</html>

note : php file must have a '.php' extension.if the file has a .html extension, the php code will not be executed.


PHP sort tags

sort tag start with <?   and  ends with ?>:

syntax:

         <?   // php code put here      ?>

note: before it used, you must need short_open_tag enabled in php.ini file.

using short tags should be avoided when developing applications.


PHP ASP-style tags

ASP-style tags mimic the tags used by Active Server Pages to delineate code blocks.

asp tag start with <%   and  ends with %>:

syntax:

         <%   // php code put here      %>

note: before it used, you must need asp_tags enabled in php.ini file.


PHP HTML script tags:

the <script> tag can be used to embed php code within an html web page.

     <script   language="php">  //php code put here   </script>