Welcome to Our Free Tutorial!

PHP-Variables!

Previous Home Continue

If you have never use any programming Algebra then variables concept might a new concept for you. Detailed explanation of variables in this tutorial.
The PHP variables means the storing the values like text string “a4avariables”, or integers values “1,2,3”. PHP Variables named “Containers” that store a value. A variable can reuse again and again in your code.
PHP defined with the following form.

$variable_name = Value;

If you forget that dollar sign at the beginning, it will not work. This is a common mistake for new PHP programmers!

Rules of Variables

  1. Variable names are case-sensitive(y and Y are two different variables).
  2. Don’t forget that dollar sign at the beginning.
  3. PHP variables must start with a alpha-numeric letter or underscore (A-Z,0-9,_).
  4. Variables name should not contain spaces.
  5. Variable name more than one word should be separated with underscores($aone_php).
  6. More then one word also distinguished with capitalization like ($aonePhp).

PHP Code

<?php
$myVariable = "PHP is Very Easy For all!";
echo $myVariable;
?>
Explanation

We have use a variable name $myVariable and use one string parameter value(PHP is Very Easy For all!).
Then we call the variable name from echo command.

Output:

PHP is Very Easy For all!

Another Example of php variables
Previous Home Continue