×

php · level 1 · unit 3 · lesson 4

  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

Double quotes fill in the gaps in your text.

Joining with dots gets fiddly. Here is a shortcut: inside double quotes, PHP spots each variable and drops its value in. So "Hi, $name!" shows Hi, Mia!.

, like 'Hi, $name!', work differently. PHP shows the text exactly as typed, $ and all, and \n stays as two characters too. Use double quotes when you want the gaps filled.

If letters follow straight after a name, PHP cannot tell where the name ends. Wrap it in : "{$pet}s" shows cats.

<?php
$name = "Mia";
$age = 9;
echo "Hello, $name! You are $age.\n";
echo 'Hello, $name!';

Numbers drop into double quotes too, so $age shows 9 with no joining needed.