Description #
PHP (Hypertext Preprocessor) is a widely-used, open-source, server-side scripting language designed specifically for web development. It is embedded in HTML and runs on the server, making it ideal for generating dynamic web pages, handling form data, managing sessions, and interacting with databases like MySQL.
History #
PHP was created by Rasmus Lerdorf in 1994 as a collection of Common Gateway Interface (CGI) scripts to track visitors to his personal website. Initially called “Personal Home Page Tools,” it evolved into PHP: Hypertext Preprocessor as it gained more functionality.
Milestones in PHP development include:
- PHP/FI (1995) – the first public release
- PHP 3 (1998) – a complete rewrite with wider adoption
- PHP 5 (2004) – introduced object-oriented programming
- PHP 7 (2015) – major performance improvements
- PHP 8+ (2020 onward) – added JIT, union types, named arguments
Today, PHP powers content management systems like WordPress, Drupal, and Joomla, and remains foundational in web hosting environments worldwide.
Hello World Code #
<?php
echo "Hello, World!";
?>
How to Run #
Using CLI (Command Line Interface): #
- Save the code in a file named
hello.php
- Run with:
php hello.php
In a Web Server: #
- Place the file in your server’s root directory (e.g.,
htdocs
for XAMPP orwww
for WAMP) - Start your local server
- Visit
http://localhost/hello.php
in your browser
Key Concepts #
<?php ... ?>
— PHP code block inside HTML
echo
— outputs data to the browser or terminal
Loosely typed — variables can change type
Runs on the server, not the browser
Supports procedural and object-oriented programming
PHP files usually end with .php
Integrates easily with MySQL and MariaDB
Extensive standard library for web functionality
Works with Apache, Nginx, and IIS
Supported by nearly all shared hosting providers
Try It Online #
🔗 PHP Fiddle
🔗 3v4l.org (PHP Sandbox)
🔗 OnlinePHP.io
Fun Facts #
PHP powers over 75% of all websites with a known server-side language
WordPress, the world’s most popular CMS, is built entirely on PHP
PHP is often mocked—but it’s still one of the most-used backend languages
PHP scripts can also generate PDFs, Excel files, and images
The official PHP mascot is an elephant named “elePHPant”