PHPLesson 1 of 13

What is PHP?

PHP is a programming language that runs on web servers. When a visitor opens a page, the server reads the PHP code, runs it, and sends the finished HTML to the browser. The visitor never sees the PHP itself, only the result. That is why PHP pages can look different for every person: the code builds the page at the moment someone asks for it.

PHP is a programming language that runs on web servers. When a visitor opens a page, the server reads the PHP code, runs it, and sends the finished HTML to the browser. The visitor never sees the PHP itself, only the result. That is why PHP pages can look different for every person: the code builds the page at the moment someone asks for it.

PHP stands for PHP: Hypertext Preprocessor. The name is recursive, a joke the creators kept. It started in 1994 as a set of personal tools and grew into the language behind a huge share of the internet. WordPress, the system that runs a large part of the web, is written in PHP. So are WooCommerce stores, Laravel apps, and countless smaller sites.

PHP mixes with HTML naturally. You can write a normal HTML page and drop PHP blocks into it with <?php and ?>. The server executes the blocks and leaves the rest of the markup untouched. For beginners this is the friendliest part of PHP: you already know HTML, and PHP is the piece that adds logic, data, and repetition.

You do not need an expensive setup to try it. A free tool like XAMPP installs PHP, a web server, and a database on your own computer in one step. You write a file, open it at localhost, and PHP runs it for you. The next lessons take you from that first file to forms, databases, and dynamic pages.

What makes PHP different from JavaScript

JavaScript in a browser runs on the visitor's machine. PHP runs on the server, before the page is sent. That means PHP can read files, talk to databases, and keep secrets, because the code never leaves the server. The visitor only receives what PHP chooses to output.

PHP
<?php
// This runs on the server, never in the browser
echo "Built at " . date("H:i:s");
?>

Where PHP lives on the web

Look at most shared hosting plans and PHP is listed in the features. It runs on every operating system, works with every major web server, and connects to MySQL, PostgreSQL, and SQLite. This wide support is why so many cheap, reliable sites still run on PHP today.

PHP
// A classic PHP file mixes HTML and code
<h1>Hello</h1>
<?php echo "This part is dynamic"; ?>

Syntax

PHP
<?php
// PHP code lives between <?php and ?>
echo "Hello from the server!";
?>

PHP Needs <?php Tag, Not Just .php File

A .php file without <?php ?> is served as plain text — code won't run. Always wrap code.

PHP
<?php echo "hi"; ?>

Good to know

  • PHP runs on the server and sends finished HTML to the browser.
  • PHP mixes into HTML with <?php and ?> blocks.
  • WordPress and huge parts of the web are built with PHP.
  • XAMPP gives you PHP plus a web server on your own computer.
Try it Yourself Edit the code, press Run, then check what changed in the Result.
Ready
Code
Result

Practice makes it stick

Open the Playground and build your own page with the tags you just learned.

→ Open Playground