PHP Variable

PHP Variable

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

Variable Tip

  1. Make all variable name in the small letter. Example $total=100;, $username=”abdxyz”; 
  2. 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
  3. Make all variable name descriptive. Example store total with GST then its $totalWithGst

Variable Trick

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

 Next Echo & Print