Guided Notes

Variables & Output

Creating variables, naming rules, echo and print, printing with variables inside strings, var_dump, and variable scope.

Variables

Slide 1 / 5

A variable stores a value and starts with a dollar sign: $city = "Cairo"; $year = 2026; $price = 9.99;

Rules for names: • start with a letter or underscore after the $, • contain only letters, numbers, and underscores, • are case-sensitive ($total and $Total are different).

PHP is loosely typed: you don't declare a type, and a variable can later hold a different kind of value. Name variables clearly — $orderTotal beats $x.

← Introduction to PHP