Syntax and types
โ Report an issue with this lesson<?php
$name = "Ada";
$age = 28;
$price = 29.99;
echo "$name is $age years old";
?>
Variables always start with $. PHP is loosely typed by
default, though modern PHP supports optional type declarations on
function parameters and return values.
Try it yourself
Exercise: Declare $name and $age, then echo them in a string.
Expected output: open-ended โ there's no single correct output here, just get your code running without errors.
Run your code and get it working before marking this lesson complete.
// free preview
9 more lessons โ including Capstone project: a course listing page โ plus a certificate are waiting.
Unlock the full course โ $149.99