Declare Variable

Posted on Updated on

UntitledDeclare Variable:

Variables are the temporary storage. Or Variable store the values or variable are container they contain the values the value is depend upon the user it may be string may be integer etc.

How to declare variable in php?


$variable _name=value;

$stu_name=”arsh”;   // this is the variable name with  stu_name and the value is arsh which is in string.

There are some rules for declare the variables:-

 variable are case sensitive

 $Name and $name is deferent.

  Blank spaces are not allowed. we can use (_) underscore at the place of blank space.


 $student name=”amrit  pal”;    // is wrong variable name can’t accept the blank space

 but value can accept the blank space.

 $student_name=”amrit pal”;   // is the right way to declare a variable with space.

  Variable not start with number  or special character.



 $#=value;             // wrong way

  $name=value;           //right way

A personal advice to declare a variable is give the relative name to the variable that we can easy understand and easy operate.don’t use the shortcut names like $a,$b etc .

How to access the variable??

 Now we know how we can declare the variable now how can access that variable.

 We can operate on the variables using the operator we can store some output and display them as result or output.

Variable use with operators:-

 $first_value=10;              //declare variable

 $second_value=20;       //declare variable

$result=$first_value+$second_value;        // works with operators



 How to show the result and concatenate with the string :-

 Echo $result;      // it show the simple result and produce the output only

 Echo “result is: ”.$result;   // it show the result with string result

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666


Please fill the FORM and we shall contact you soon.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s