What is PHP?
PHP (Hypertext Preprocessor) is a widely-used server-side scripting language designed for web development. Created by Rasmus Lerdorf in 1994, PHP powers over 75% of websites, including WordPress, Facebook, and Wikipedia.
PHP code runs on the server and generates HTML that is sent to the browser. It's embedded directly in HTML, making it easy to add dynamic functionality to web pages.
- Server-side language — runs on the web server
- Easy to learn with C-like syntax
- Powers WordPress, Laravel, Drupal, and Magento
- Excellent database support (MySQL, PostgreSQL)
- Large community and extensive documentation
- Free and open source
Your First PHP Script
PHP code is enclosed in tags. When the server processes the file, it executes the PHP and sends the output to the browser.
Example
<?php
// This is a PHP comment
echo "Hello, World!";
?>
<!-- PHP embedded in HTML -->
<!DOCTYPE html>
<html>
<body>
<h1><?php echo "Welcome to PHP!"; ?></h1>
<p>Today is <?php echo date("Y-m-d"); ?></p>
</body>
</html> 