🎯 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
<?phpand?>(the closing tag is optional at the end of a file). echooutputs text; every statement ends with;.- Comments:
//,#and/* … */.
Finished reading & practising?
Saved in this browser. Create a free account to keep it forever.