What is PHP?
A server-side language that builds web pages dynamically — behind WordPress, Facebook’s early days, and the Laravel framework.
What you will learn
- Explain what PHP is and where it runs
- Understand server-side vs client-side
- See how PHP builds a page
A server-side language
PHP (PHP: Hypertext Preprocessor) is a server-side language. It runs on the server, builds an HTML page, and sends that finished HTML to the browser. The visitor never sees the PHP — only the result.
It powers a massive part of the web — WordPress, Wikipedia, and the Laravel framework you will learn next are all PHP.
| PHP (server-side) | JavaScript (client-side) | |
|---|---|---|
| Runs on | The server | The browser |
| Can access | Databases, files, secrets | The page (DOM), the user |
| Visitor sees | Only the HTML output | The actual JS code |
<!DOCTYPE html>
<html>
<body>
<h1>Welcome</h1>
<?php
echo "<p>This paragraph was built by PHP on the server.</p>";
?>
</body>
</html>Note: The browser receives only: <h1>Welcome</h1><p>This paragraph was built by PHP on the server.</p> — the PHP ran and disappeared, leaving HTML.
Tip: Because PHP runs on the server with access to databases, it is perfect for logins, dynamic content and data-driven sites — exactly what Laravel makes easy.
Q. Where does PHP code run?
✍️ Practice
- List three popular websites or tools built with PHP.
- In your own words, explain server-side vs client-side.
🏠 Homework
- Write two sentences on why server-side code can safely access a database but client-side code should not be trusted with secrets.