Variables and Data Types
6 min read Quiz at the end
Variables store data in PHP and always start with a dollar sign like $name or $age. PHP automatically detects the type — string, integer, float, boolean, or array. You can change a variable value anytime during the script execution.
Variables in PHP
PHP variables start with $ and are loosely typed.
$name = "Alice";
$age = 25;
$gpa = 3.8;
$active = true;
Data Types
- String — Text
- Integer — Whole numbers
- Float — Decimals
- Boolean — true/false
- Array — List of values
- NULL — No value