0PricingLogin
PHP Academy · Lesson

Variables and Constants

Learn how to use variables and constants in PHP.

1

Variables and Constants

Welcome to a new chapter in your PHP journey! In this lesson, you’ll learn how to use variables to store data and constants to define unchangeable values. Let’s get started!

Variables and Constants — illustration 1

2

What Are Variables?

Variables are used to store data that can change during the execution of a script. In PHP:

  • Variable names start with a $ symbol.
  • They can store different types of data like strings, numbers, and arrays.

Example:

<?php
  $name = "Alice";
  $age = 25;
  echo "Name: $name, Age: $age";
?>

All lessons in this course

  1. Variables and Constants
  2. Data Types
  3. Operators
  4. Control Structures
  5. Working with Arrays
← Back to PHP Academy