LESSON 01 / 05

Meet PHP

PHP runs on the server and builds web pages before they reach the browser. It powers WordPress — and about three quarters of all websites that use a server language.

🎓Beginnerlevel
⏱️25 minto finish
✏️2activities

📂 PHP Basics🏷️ PHP basics

🎯 By the end of this lesson you can…

  • Explain where PHP runs
  • Write and run your first PHP program
  • Use echo and comments
🐘 PHP hello.php 👆 Tap a line to explain it
1<?php2// This is a comment.3echo "Hello from PHP! 🐘\n";4echo "2 + 3 = ", 2 + 3, "\n";5echo "Today is ", date("l"), "\n";

PHP builds HTML

On a real website, PHP’s output is the HTML page:

🐘 PHP page.php 👆 Tap a line to explain it
1<?php $name = "Asha"; ?>2<h1>Welcome, <?php echo $name; ?>!</h1>3<p>You have <?= 3 ?> new messages.</p>
💡 Concept check
Where does PHP code run?
🛠️ First PHP

Print exactly two lines: I am learning PHP and the result of 12 * 11.

📌 Key takeaways

  • PHP code lives between <?php and ?> (the closing tag is optional at the end of a file).
  • echo outputs text; every statement ends with ;.
  • Comments: //, # and /* … */.

Finished reading & practising?

Saved in this browser. Create a free account to keep it forever.