Thuta Learning
BasicProgrammingbeginner

Variables

Relax. We'll talk through this in plain words — no textbook voice.

Think of a variable as a little box that holds data. In PHP, a variable name starts with a dollar sign $, and names are case-sensitive. $name and $Name are not the same.

php
<?php
$greeting = "Hello";
$name = "Aung Aung";
$age = 25;

echo $greeting . " " . $name . "!<br>";
echo "You are " . $age . " years old.";
?>
You should see
Hello Aung Aung! You are 25 years old.

Easy traps

  • If you set $age but then try to call $Age, you'll get an undefined variable warning.