PHP Variable

PHP variable

Variable is simply storing some value inside and use in the program.
In PHP, you can make variable using $ sing.
Example $a=”Hello World!”; $x=10;
In variable you can store Strings and numbers.
You can assign a value using = Sing (the left side you variable name = right side your value ).

Variable Tip

Make all variable name in the small letter. Example $total=100;, $username=”abdxyz”;
IF variable have two word combination like username then user camel case
Example $userName=”Hello World!”; $firstName=”jignesh”; In camel case second word first letter is capital
Make all variable name descriptive. Example store total with GST then its $totalWithGst

Variable Trick

$total=100;, $a=10;
Assign string value using signal quotation and dual quotation $userName=”Hello World!”; $firstName=’jignesh’;