Develop a new think

PHP Variables

Variables are used for storing values, such as numbers, strings or function results, so that they can be used many times in a script. Variables are denoted with a dollar sign ($) and are case-sensitive($a and $A are not the same thing). The first letter of the variable name must be an underscore or letter and cannot be a number.
Variables also do not need to be defined or declared and can simply be assigned when needed. Variables can hold either numeric or text values.
$var_name = value;
<?php
$name = "Rocky";
$age = 16;

echo "hi, I am ";
echo $name;
echo ". I am ";
echo $age;
echo "yrs old guy.";
?>
hi, I am Rocky. I am 16 yrs old guy.

Define

You can also define the variable like this.
define(constant_name,value);
<?php
define("myGame", "Criket");
echo "My favorite game is ";
echo myGame;
echo "<br />";
?>
My favorite game is Criket

Next: Strings

All links Introduction | Installation | Syntax | Variables | Strings | Operators | Comments
web counter