What is PHP Variables?



We assume that some of you haven’t done any programming , We understand that variable may be a new concept. A variable stores a value ,such as the text string “Hello World!” or the integer value 1. A variable can then be reused throughout your code, instead of having to type out the actual value over and over again for entire life of the variable ,which can be frustrating and tedious.

Following are a example of created a variable that has assigned a value of 30, see this is the most important topic in variable: 

In PHP Page :                        

                                   <?php
                                                           
                                             $age= 30;

                                    ?>

In Memory :                            

                               $age    the value   30

In PHP we Define a variable with following  form:

                              $variable_name= value;


Pay very close attention to some key elements in the form of variables.The dollar sign ($)  must always fill the first space of your variable.The first character after that the dollar sign must be either a letter or an underscore.It can’t under way circumstance be a number ; otherwise ,your code won’t execute ,so whats these typos!

  1. PHP variable may be composed only alphanumeric characters and underscore,for example a-z,A-Z,0-9 and _,
  1. Variable in PHP are case-sensitive. 

Categories: PHP

Leave a Reply

Your email address will not be published. Required fields are marked *