php · level 1 · unit 1 · lesson 4
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
An is a clue, not a disaster.
An error is PHP saying it got stuck. Everyone gets them, even experts. The message tells you the kind of error, what went wrong, and the line number to look at.
A means PHP cannot read your code, like a sentence with words missing. Often a ; or a quote mark has gone astray. A missing ; is usually reported on the line after it.
An Error that says means PHP met a word it does not know. Forget the quotes in echo Hello; and PHP hunts for something called Hello that nobody has made.
PHP stops at the first error it meets, so fix one slip at a time and run again.
guess first
Line 2 has lost its ;. What happens?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<?php
echo "Hello!\n"
echo "Goodbye!\n";
your turn
Your turn. Close everything you open.
Type your superpower in place of the blank. Then finish the line: close the quotes, add the ;, and press run.
fix it
Breakfast is broken. Can you fix it?
- Read the error. Which kind is it, and which line does it name?
- It is a ParseError on line 3. Count the quote marks on that line.
- A string needs a quote mark at both ends. Add " before Come, then press run.
nailed it
you turned errors into clues. :D
- Errors are clues: read the kind, the message and the line.
- A ParseError often means a missing
;or quote mark. - Check the line the error names, and the line above.
new words in your collection
- error
- ParseError
- undefined
This lesson isn’t saved. A free account remembers every lesson you finish.