← Back to PHP Course | Chapter 1: Introduction & Basics | Lesson 2 of 13

PHP History & Features

PHP started as a tiny homemade tool one person built to count visitors to his own web page. Over the years it grew, like a small lemonade stand that turned into a big shop.

History of PHP

Rasmus Lerdorf wrote the first version in 1994 as a small set of tools for tracking visits to his own personal homepage, hence the original name 'Personal Home Page.' It was rewritten and renamed to the recursive 'PHP: Hypertext Preprocessor' as it grew from a personal script collection into a general-purpose web language.

Example: History of PHP

php
<?php
// Rasmus Lerdorf's 1994 "Personal Home Page" tools grew into PHP: Hypertext Preprocessor
echo "PHP has been evolving since 1994.";
?>

Open Source

PHP's source code and interpreter are free to use and modify, and decades of contributions from a large open community have shaped its standard library, its performance, and major language shifts like PHP 7's speed improvements and PHP 8's JIT compiler.

Example: Open Source

php
<?php
// Anyone can inspect or modify the PHP interpreter itself -- it's open source
echo "PHP version running here: " . phpversion();
?>

Platform Independence

The same PHP script generally runs unmodified on Windows, Linux, or macOS, because PHP itself handles the platform differences (file paths, line endings, and so on) rather than pushing that burden onto your code — a big reason it became a default choice for portable web hosting.

Example: Platform Independence

php
<?php
// The same script runs unmodified on Windows, Linux, or macOS
echo "Directory separator on this OS: " . DIRECTORY_SEPARATOR;
?>

Speed and Efficiency

Modern PHP (especially PHP 7 and 8) compiles to optimized bytecode and, since PHP 8, can JIT-compile hot code paths, which closed much of the performance gap that once existed between PHP and lower-level languages for typical request/response web workloads.

Example: Speed and Efficiency

php
<?php
// Declare `$start`, set to `microtime(true)`
$start = microtime(true);
// Classic for-loop: `$i = 0; $i < 100000; $i++`
for ($i = 0; $i < 100000; $i++) {
    // Declare `$total`, set to `$i * 2`
    $total = $i * 2;
}
// Print "Compiled bytecode ran in " . round(microtime(true) - $start, 4) . "s" to the output
echo "Compiled bytecode ran in " . round(microtime(true) - $start, 4) . "s";
?>

Loose Type Language

PHP is loosely typed: you don't declare a variable's type up front, and PHP converts between types automatically when an operation needs it (e.g. combining a string and a number).

This lowers the barrier to writing your first working script, though it's also why PHP added optional strict typing and type declarations in later versions for larger codebases.

Example: Loose Type Language

php
<?php
$value = "5" + 3;
echo $value;
// PHP converted the string "5" to a number automatically
?>
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Assuming PHP is slow because of old benchmarks, when PHP 7 and 8 compile to optimized bytecode (with opcache) and are far faster than PHP 5.
  2. Following tutorials written for PHP 5 and using removed features like the mysql_* functions, which no longer exist in modern PHP.
  3. Assuming a script written for one PHP version runs unchanged on any other, without checking the version-specific changes such as those introduced in PHP 8.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.