Breaking

LightBlog

Saturday 4 July 2015

PHP Variable


PHP variable
Variable are used to store the value such as string, numeric or function results, so that they can be used many times in script. You can declare the $ dollar sign before the variable name. This is require to make the PHP parser faster, as it instantly knows whenever it comes across a variable. The variable syntax is given below.
        $variable name=value;
        $a=20; 

                         
php variable
String variable
The string variable is used to store the string value that can enclose with the double quote such as
     
<html>
<body>
<?php
$value =200;
echo "the value is ".$value;
             ?>

Numeric variable
Just name indication the numeric variable van used to store the numeric value they cannot store the string value such as.
<html>
<body>
<?php
$value =200;
echo "the value is ".$value;
?>                                    

Variable naming rule
      A variable name must start with a letter or underscore “  _  ”.        
      A variable name can only contain alpha-numeric character and underscores (a-z,A-Z,0-9 and-)    
      A variable name should not contain the space. If a variable name is more than one word it  should be            separated with underscore ($first_name), or with capitalization ($firstName).    
      A Variable cannot start without the dollar sign($).
 
PHP automatically converts the variable to the correct data type, depending how they are set.
        
                                               
     
         
                 
    

                                                                                   
Adbox