Variables

  • STEP
    Variable is a container used to store data

    Eg: An excel file name is a variable. It contains data

    1. Define variable or variable assignment

    Syntax:

    
                    $variable_name = value;
                  
    1. $ sign must be in front of the variable name
    2. = sign is for assigning the value to a variable
    
                  <?php 
    
                  $name="manoj";
                  $age=20;
                  $dob="20-01-2020";
                  $english=50;
                  $malayalam=50;
                  $computer=50;
                  $maths=50;
                  $gk=50;
    
                  ?>
    
                

    2. read variables

    
                  <?php 
                  
                  $name;
                  $age;
                  $dob;
                  $english;
                  $malayalam;
                  $computer;
                  $maths;
                  $gk;
    
                  ?>
    
                

    3. output the variable data into browser

    
                  <?php 
                  
                  echo $name;
                  echo $age;
                  echo $dob;
                  echo $english;
                  echo $malayalam;
                  echo $computer;
                  echo $maths;
                  echo $gk;
    
                  ?>
    
                

    4. Change the value of a variable

    
                  <?php 
    
                  $name="manoj1";
                  $age=20;
                  $dob="20-01-2020";
                  $english=50;
                  $malayalam=50;
                  $computer=50;
                  $maths=50;
                  $gk=50;
    
                  ?>
    
                

    5. Display the data user friendly

    
                    <table>
                        <tr>
                            <td>Name</td>
                            <td> 
                                <?php                              
                                  echo  $name; 
                                ?>
                            </td>
                      </tr>
    
                      <tr>
                            <td>Age</td>
                            <td> 
                                <?php                              
                                  echo  $age; 
                                ?>
                            </td>
                      </tr>
    
                      <tr>
                            <td>DOB</td>
                            <td> 
                                <?php                              
                                  echo  $dob; 
                                ?>
                            </td>
                      </tr>
    
    
    
                    </table>