A variable is used in programming to represent another value. In PHP variables all start with a dollar sign ($). They can be set to a string or a numeric value.
More PHP / MySQL Quick Tips
<?phpYou will notice that string values are contained with quotations [""] while numeric values are not. Instaed of just a static number, you can also set a variable equal to an equation. Here are some examples:
$a = "Alexa";
//This sets the variable $a to a string value (Alexa)
$b = 6;
//This sets the variable $b equal to a number value (6)
?>
<?phpWe can combine values using a period [.] This will literally mash the values together. Here are some examples:
$a = 3 + 5;
//This sets the variable $a equal to 8 or (3 + 5)
$b = 6 + $a;
//This sets the variable $b equal to 14, or (6 + $a)
?>
<?phpThis is different than just echoing both variables as a new variable is actually created from the other variables.
$a = 1;
$b = 2;
$c = $a.$b;
//The value of $c is now 12, because we smashed the 1 and 2 together
$d= $c + 1 ;
echo $d;
// This will echo 13, our newly created 12 plus 1 is 13
$e = "Number";
$f = $e.$d;
echo $f;
//This will echo the string Number13, a combination of $e and $f
?>
Another thing you can do is make a variable from a string by using {} symbols. So, by using this method you could pass a string from one page to another, and use that string to pull the information from a variable of the same name. Here is an example:
<?phpThis will return "test", which is the value of $SomeVar because by using the {} symbols we are creating the variable from the string in $a.
$a= "SomeVar";
$SomeVar= "test";
echo ${$a};
?>

