Searching...
Monday 10 September 2012

PHP Basic Syntax

10:21 pm

                            PHP Basic Syntax

PHP Basic Syntax :

PHP Basic Syntax

1.       A php programe contains html tags , plain text and php scripts.
2.       A php programe is same with extension of .php.
3.       In a php programe server side php scripts are written inside a php block.
4.       A php scripting block can be placed any where in the document and any number of times.
5.       A standard php scripting block always starts with <?php and ends with ?> - which is under standable for any web server that supports php.

    <?php
     -------------
     -------------
   ?>
On web servers with short hand support enabled , you can start a php scripting block with <? And ends with ?> and also Asp style block <% and %>
 <?                                                    <%
   ---------------                                                            ------------------
   ---------------                                      ------------------
  ?>                                                    %>
6.       Short hand open block and asp style block will be allowed by a web server only if it is configured in php.ini.
7.       Php.ini is present in c:\xampp\php folder . open php.ini file and search for the value of  “short-open-tag” and “ asp-tags” to identify whether the web server supports short open block (OR) asp block.
Echo()             these are language constructs
Print()
#           ----------             single line comment
$           ----------             variable
1.       Echo and print are the two language constructs or built-in function of php used for outputting text or to give response back to client.
2.       Differene between echo and print : echo() is faster in execution than print(). Print() is return an “integer”  value where as echo() will not return a value.
3.       The semicolon ( ; ) is a separator and is used to distinguish or separate one php script from another.
Comments in PHP :
1.       Single line comments  -  // or #.
2.       Block comments start with  /*  and ends with */ .

0 comments:

Post a Comment