Variables
Every PHP variable name starts with $:
$name = "Ada";. Like Python or JavaScript, you don't declare
a type — it's inferred from whatever value you assign.
Example: variables inside a string
<?php
$name = "Ada";
$age = 21;
echo "$name is $age years old.";
?>
Ada is 21 years old.
Variables placed directly inside a double-quoted string
("$name") are automatically substituted with their value —
this only works inside double quotes; single-quoted
strings ('$name') print the literal text $name
instead, with no substitution at all. That distinction catches a lot of
beginners the first time they switch quote styles without thinking about
it.
<?php
$name = "Ada";
$age = 21;
echo "$name is $age years old.";
?>
Ada is 21 years old.