Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Introduction to PHP  ›  Lesson

What PHP Is and Where It Came From

What is PHP? 12 minPHP is a server-side scripting language that runs code on the web server and sends only the resulting output, usually HTML, to the browser.

What PHP Is and Where It Came From

Pageturn is a small online bookshop. Every visitor should see today's prices and whether Dune is in stock, so the page must be built fresh for each request. That is the job PHP was made for.

The rule

PHP runs on the server, builds the page, and sends only the result.

What it is. PHP is a general-purpose scripting language that is best known for building web pages on the server. The name is a recursive acronym: PHP: Hypertext Preprocessor. A PHP file can mix plain HTML with code:

<p>Dune costs <?php echo 9.99; ?> today.</p>

The browser asks for the page, the web server hands the file to PHP, PHP runs the code, and the browser receives only <p>Dune costs 9.99 today.</p>. The visitor never sees the PHP source.

Where it came from. In 1994 Rasmus Lerdorf wrote a few small tools to track visits to his personal home page. Others wanted them, and they grew into a language. Key milestones:

  • PHP 3 (1998): rewritten by Andi Gutmans and Zeev Suraski; the first version that looks like modern PHP.
  • PHP 4 (2000): the Zend Engine arrived underneath.
  • PHP 5 (2004): proper classes and objects.
  • PHP 7 (2015): roughly twice as fast, plus type declarations for scalar values. (PHP 6 was abandoned, so the numbering skipped it.)
  • PHP 8 (2020 onward): match, named arguments, the nullsafe operator ?->, union types and a JIT compiler; later 8.x releases added enums, readonly properties and more.

This course uses PHP 8.x; check the date on older tutorials before copying a pattern.

Running it yourself. Beginners often install a bundle that packages a web server, PHP and a database together: XAMPP (any system), WAMP (Windows), MAMP (macOS) or a LAMP setup on Linux. You only need PHP itself to start, though: php -S localhost:8000 runs a small built-in development server in the current folder.

The shortcut

When you meet any PHP snippet, ask "what arrives at the browser?" Picture the server running the code first, then imagine the plain text that is left.

One request to PageturnStep 1 of 3
  1. The browser asks

    A visitor opens /book.php. The request goes to the web server.

The common mistake is thinking PHP runs in the browser, like JavaScript. It cannot react to a click until a new request reaches the server.

Drills

Answer fast — trust the rule.

quick drill

Where does PHP code execute?

quick drill

A visitor opens View Source on a PHP page. What do they see?

quick drill

Which release first brought the match expression and named arguments?

quick drill

What is the smallest setup that lets you run PHP pages locally?

Remember

  • PHP runs on the server, builds the page, and sends only the result.
  • Shortcut: ask "what arrives at the browser?"
  • Trap: PHP is not browser code, and advice written for PHP 5 may be out of date.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhat does the browser receive?

A friend says PHP is like JavaScript because both run on web pages. Using a Pageturn book page that shows today's price, explain where PHP runs, what the browser actually receives, and why a visitor cannot see the PHP code.