PHP Variables
Variables in PHP start with $ followed by the name. PHP is dynamically typed.
$name = "Alice";
$age = 30;
$price = 19.99;
$active = true;Data Types
- string — text
- int — whole numbers
- float — decimal numbers
- bool — true/false
- array — ordered collections
- object — class instances
- null — no value
- resource — external resources
Type Casting
$num = (int) "42";
$str = (string) 100;Variable Scope
Variables declared outside a function are global. Use global keyword or $GLOBALS array to access them inside functions.