×

php · level 1 · unit 2 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

A is a box with a name on it.

A variable is a box with a name on it. You put a in the box, such as a string, and from then on you use the name to get it back.

In PHP every variable name starts with a dollar sign, like $name. Read = as put into: $name = "Sam"; puts "Sam" into the box called $name. Then echo $name; shows what is inside.

Spell the name differently and PHP finds no box with that name. It stops with an that says Undefined variable.

<?php
$name = "Sam";
echo $name;

Say $name = "Sam"; out loud as: put Sam into the box called name.