What is PHP?
PHP (Hypertext Preprocessor) is a widely used server-side scripting language designed primarily for web development. Created by Rasmus Lerdorf in 1994, PHP now powers over 75% of websites with a known server-side language — including WordPress, Facebook (historically), and Wikipedia.
Where is PHP used?
- Web backends — Dynamic web pages, REST APIs, CMSes
- WordPress — The most popular CMS in the world runs on PHP
- E-commerce — WooCommerce, Magento, OpenCart
- Frameworks — Laravel, Symfony, CodeIgniter
Why learn PHP?
- 🌐 Runs on virtually every web hosting provider
- 🚀 Easy to get started — embed in HTML directly
- 📚 Massive ecosystem with Composer package manager
- 💼 Huge job market — millions of WordPress sites need PHP developers
Your first PHP program
<?php
echo "Hello, World!";
?>
PHP code is embedded between <?php and ?> tags. The echo statement outputs text. For CLI scripts, you can run: php hello.php.
PHP in HTML
<!DOCTYPE html>
<html>
<body>
<h1><?php echo "Hello from PHP!"; ?></h1>
<p>Today is <?php echo date("Y-m-d"); ?></p>
</body>
</html>
PHP is processed on the server — the client only sees the resulting HTML. This is what makes it a server-side language.