\n\n\n\n\n

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!

🚀 Ready for More?

These free lessons are just the start! Enroll for:
✓ Certificates
✓ Advanced projects
✓ Mentor support
✓ Career guidance

↗ Unlock Full Access
📚 Module 2: Variables & Data Types
📖 Browse Courses