PHP variables are used to store data like numbers, strings, or arrays. A variable starts with the $
symbol.
// Declaring variables <?php $name = "Ali"; // String $age = 25; // Integer $height = 5.9; // Float $isStudent = true; // Boolean ?>
Text inside quotes like "Hello"
or 'World'
.
$text = "Academy of Information Technology";
Whole numbers without decimal.
$age = 20;
Numbers with decimal point.
$price = 99.99;
Only two possible values: true
or false
.
$isLogin = true;
Collection of multiple values in a single variable.
$students = ["Ali", "Sara", "Ahmed"];
Variable with no value.
$result = NULL;
$Name
and $name
are different.$
and a letter or underscore, not a number.