PHP (PHP: Hypertext Preprocessor) is a server-side scripting language. PHP code runs on the web server, and the browser receives only the resulting HTML.
How PHP works
- The visitor opens
index.php - The server runs the PHP code (reads the database, checks login, etc.)
- The server sends plain HTML back to the browser
That is why visitors can never see your PHP code — only its output.
What can PHP do?
- Create dynamic pages ("Welcome, Asha")
- Handle forms: contact, login, registration
- Read and write a MySQL database
- Manage sessions and cookies
- Upload files, send emails, generate PDFs
- Build REST APIs that return JSON
Why learn PHP?
- Powers WordPress, Laravel, Facebook (originally), Wikipedia
- Runs on almost every cheap hosting plan
- Easy to start, with huge job demand in India for PHP/Laravel developers
You should know basic HTML before starting. This tutorial uses PHP 8.
Example
Example — Your first PHP page
PHP
<!DOCTYPE html>
<html>
<body>
<h1><?php echo 'Hello from PHP!'; ?></h1>
<p>Today is <?php echo date('l, d F Y'); ?>.</p>
</body>
</html>
Output in the browser: a heading "Hello from PHP!" and today's date, e.g. "Today is Tuesday, 01 December 2026." View the page source — you will see only HTML, no PHP.