Challenge 3 — Solution
Task: Write a PHP block with three separate echo statements that together
output three lines (use "
" at the end of each string to force a line
break in the browser): your name, your favourite number, and a
one-sentence comment about why you're learning PHP.
";
echo "My favourite number is 7.
";
echo "I'm learning PHP because so much of the real web still runs on it.
";
?>
Output:
My name is Philip.
My favourite number is 7.
I'm learning PHP because so much of the real web still runs on it.
Notes:
- Each echo statement is entirely separate — PHP doesn't remember
anything about the previous line automatically.
- The "
" at the end of each string is plain HTML, not PHP syntax —
it's simply part of the text being echoed, and the browser renders it
as a line break exactly as it would for any other HTML in the page.
- Without "
" (or a real newline that HTML would respect), all three
echo calls would run together on a single visual line in the browser,
even though the PHP code itself has them on separate lines.