Lesson 2.1: Variables
📖 Introduction to PHP
⏱️ 20 min
Variables are containers for storing data values. In PHP, variables start with the $ symbol.
Declaring Variables:
<?php
$name = "John";
$age = 25;
$height = 5.9;
echo "Name: " . $name;
echo "Age: " . $age;
?>
Variable Naming Rules:
- Start with $ followed by a letter or underscore
- Can only contain alphanumeric characters and underscores (A-z, 0-9, _)
- Variable names are case-sensitive ($name ≠ $Name)
✓ Free Lesson
This lesson is completely free. No enrollment required. Continue learning!