×

php · level 1 · unit 7 · lesson 2

  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 slot where your function catches information.

Right now your function does the same thing every time. Cut a slot in the front, and you can feed in something new on each go. That slot is a parameter, like $name in function greet($name).

The value you drop in when you call is the . Call greet("Mia") and $name holds "Mia". Call greet("Leo") and the same machine greets Leo instead.

A function cannot see the boxes outside it. If it needs a value, hand it over as an argument. Inside, the parameter works like any other variable.

<?php
function greet($name) {
    echo "Hello, $name!\n";
}
greet("Mia");
greet("Leo");

For two slots, separate the parameters with commas, and the arguments too.