0.1 · What is PHP? Its role

Getting started

0.1What is PHP? Its role

Goal: Understand what PHP is (a server language that generates HTML) and the request → PHP → HTML cycle — the conceptual basis of every dynamic page.
Estimated time: 10 min · self-paced reading · If you only have 5 min: read “The essentials in 30s” + the diagram.

The essentials in 30 seconds

  • PHP = a server-side language for the Web: it runs on the server, never in the browser, and generates HTML.
  • Request → PHP → HTML cycle: each page request replays the cycle — the server executes, the browser displays.
  • The visitor never sees your code: they only receive the resulting HTML — logic and security stay server-side.

Running mini-case — Riad places his first dynamic page

Riad, a web developer in Constantine, only knows static HTML and a little JavaScript. His client asks him for a page that displays "Hello" with the first name of each logged-in visitor. Riad discovers that PHP runs server-side: on each request, the server executes his code, which generates personalized HTML, and the visitor only receives that HTML — never the code. He notes on a card "request → PHP → HTML" and picks his first test: a page that displays a different first name depending on the user.

Self-contained case for this section: it returns in the lesson, diagram, script and 48h challenge of section 0.1.

1. A server-side language

PHP (PHP: Hypertext Preprocessor) is a programming language designed for the Web, running server-side. Two worlds to distinguish: the client side (the user's browser), which runs HTML, CSS and JavaScript — what is displayed and animated; and the server side (the remote machine hosting the site), which runs the logic: forms, database, authentication. PHP lives server-side: when a visitor requests a page, the server executes the PHP code, which produces HTML, and it is that HTML — not the code — that is sent to the browser. The visitor never sees your PHP code. Riad remembers the picture: the kitchen (server, invisible) prepares, the dining room (browser) only sees the dish served.

2. The request → PHP → HTML cycle

The cycle to remember above all: request → PHP → HTML. (1) The user requests a page (they type a URL or click a link) — that is the request. (2) The web server receives the request, sees a .php file and hands it to the PHP interpreter, which executes the code (calculations, database access, logic). (3) PHP generates HTML, which the server sends back to the browser, which displays it. On each request, this cycle replays — and the page produced is often personalized (depending on the user, the time, the data): it is a dynamic page, as opposed to a static HTML page that is always identical. Riad understands: his "Hello + first name" is not hard-coded, it is generated on each visit.

3. A massively used, modern language

PHP powers a huge share of the Web — including WordPress, which alone runs an immense proportion of sites — as well as shops, CMSs and business applications, up to large applications via frameworks like Laravel or Symfony (level 4). It is an accessible language (easy to get started), pragmatic (made to ship sites quickly) and mature: modern versions (PHP 8+) are performant and rich (typing, full object-oriented programming, exceptions). Its bad reputation comes from its early versions — modern PHP has nothing to do with them. Riad noted it at the bottom of his card in Constantine: learning PHP is investing in a living market, with concepts (server, database, security) transferable everywhere.

Common misinterpretation: "PHP is outdated, and anyway it runs in the browser like JavaScript". No, two mistakes in one. First the execution place: PHP runs on the server, never in the browser — the visitor only receives the generated HTML, never the code. Then the alleged decline: that reputation targets old PHP; modern PHP (PHP 8+) is performant, typed and tooled (Composer, Laravel, Symfony, PHPUnit) and powers a huge share of the Web. PHP and JavaScript are not competitors: they are complementary, one server-side, the other browser-side.
The cycle of a PHP page Request → PHP → HTML: the cycle replays on each request. Request The userrequests a pageServer Hands the .php tothe interpreterPHP executes Logic,database, calculationsGenerated HTML Sent backto the browser
Request → PHP → HTML: the cycle replays on each request.
Text version of the diagram (SEO / screen readers / translation): 1) Riad, a web developer in Constantine, discovers PHP: a language executed server-side, which generates HTML sent to the browser. 2) Each request replays the request → PHP → HTML cycle: the server executes the code, the browser displays the result. 3) The page produced is dynamic and personalized (first name, data, time), unlike static HTML. Lesson: logic and security live server-side; PHP and JavaScript are complementary.

Did you know? The invisible kitchen of the Web

undefined
undefined
undefined
undefined
undefined
undefined

The server cooks, the browser only serves.

🔎 Concrete example — 🔎 Concrete example — Static vs dynamic

A page that adapts to each visitor.

Hello " . $prenom . "";
// The browser receives ONLY this HTML, never this code

Reading: Riad requests the page: the server executes the code with the visitor's first name and returns personalized HTML.

Lesson: the same URL produces different HTML depending on the user — it is a dynamic page; the logic stays safe server-side.

Section vocabulary

PHP
Server-side programming language designed for the Web (PHP: Hypertext Preprocessor); it runs on the server and generates HTML sent to the browser.

Simple example: Riad writes a page that displays the first name of each logged-in visitor in Constantine.

What it is not: a language that runs in the visitor's browser.

Reflex: facing a personalized page, ask "what is PHP generating here?".

Server side vs client side
Server (PHP): runs the logic (forms, database, authentication) and generates the pages. Client (browser): displays the HTML/CSS and runs JavaScript.

Simple example: Riad places the password check server-side, and the menu animation browser-side.

What it is not: two names for the same place.

Reflex: place each task on the right side: sensitive = server, animation = client.

Request → PHP → HTML cycle
The user requests a page → the server executes the PHP code → PHP generates HTML → the browser displays it. This cycle replays on each request.

Simple example: Riad reloads his page: each time, the server re-executes and regenerates the HTML of the day.

What it is not: a single execution when the server starts.

Reflex: think "on each request, the cycle replays".

Dynamic page
Page generated by the server, often personalized (depending on the user, the data); as opposed to a static HTML page that is always identical.

Simple example: Riad displays a different profile for each visitor instead of a fixed page.

What it is not: an identical HTML file for everyone.

Reflex: as soon as content varies, plan server-side generation.

PHP interpreter
The program that executes PHP code on the server; the visitor never sees the PHP code, only the resulting HTML.

Simple example: Riad installs the interpreter locally: his .php files execute instead of displaying as text.

What it is not: the browser, which would know how to read PHP.

Reflex: if PHP code displays as plain text, the interpreter is missing.

In practice — In practice — Placing PHP and its cycle

  1. Remember what PHP is: a SERVER-SIDE language (executed on the server, not in the browser) that generates HTML.
  2. Memorize the request → PHP → HTML cycle: on each page request, the server executes the code and returns the resulting HTML.
  3. Understand the difference from client-side JavaScript: the visitor sees the HTML produced, never your PHP code.
  4. Place the use cases: dynamic, personalized pages (forms, accounts, data), from small sites to large applications (WordPress, Laravel, Symfony).
You understand what PHP is (a server language that generates HTML) and the request → PHP → HTML cycle — the conceptual basis of every dynamic page.

Script ready to say — explaining PHP to a colleague (30 s)

"PHP is our server-side language: when a visitor requests a page, the server executes our PHP code, which generates personalized HTML, and the browser only displays that HTML. The visitor never sees our code — that is why we put logic and security there."

Say while showing the cycle diagram; stress "never the code, only the result".

Copy-paste template — first server-side generation

Hello " . $prenom . "";
echo "

Page generated server-side.

";

Coming from static HTML

You used to make fixed pages: spot what varies (first name, date, content) and hand exactly those parts to PHP; the rest stays pure HTML.

Coming from JavaScript

You animated browser-side: keep visible interactivity there, and move to PHP everything that must stay secret (passwords, database access, rules).

Pairing in Constantine

Riad shows his colleague the source code received by the browser (only HTML) next to his .php file: whoever finds a line of PHP in the browser has lost.

Project choice

Before a site: list the fixed content (HTML) and the variable content (PHP) — if everything is fixed, PHP is useless; as soon as there are accounts, forms or data, it becomes essential.

✓ Best practices

  • Place logic and security server-side (PHP), never client-side alone.
  • Think "on each request, the cycle replays".
  • See PHP and JavaScript as complementary (server/client).

✗ Common pitfalls

  • Believing PHP runs in the browser (it is server-side).
  • Trusting the client side for security.
  • Confusing a static page (fixed) with a dynamic page (generated).

Key takeaways

  • PHP is a SERVER-SIDE language: it runs on the server and GENERATES HTML sent to the client. The visitor never sees the PHP code.
  • Fundamental cycle: REQUEST (the user requests a page) → PHP (the server executes the code) → HTML (generated and displayed). Replays on each request.
  • PHP produces DYNAMIC, personalized pages (depending on the user, the data) — vs a static HTML page that is always identical.
  • Massively used on the Web (WordPress and a large share of sites); accessible, pragmatic, mature (performant PHP 8+). From small sites to large apps (Laravel, Symfony).

48h challenge — apply tomorrow

Open a page of your choice, display its browser-side source, and explain out loud why you see no PHP code there (request → PHP → HTML cycle).

Section exit checklist
  • I can explain PHP (a server language that generates HTML) with the request → PHP → HTML cycle.
  • I know how to say what the visitor sees (the HTML) and what they never see (the PHP code).
  • I can tell a static page from a dynamic page with an example.
Self-rating 1-5: can I explain the cycle without placing PHP in the browser?Self-rating 1-5: did I name a dynamic use case (form, account, data) without help?

Frequently asked questions

Is PHP outdated compared to newer technologies like Node.js or Python?

No, that is a misconception based on its past. PHP has a long history and its early versions had real flaws, hence its bad reputation — but the language has deeply changed. Modern PHP (7, then 8+) is very performant (spectacular gains), rich (typing, full OOP, exceptions, enums, attributes), with a mature ecosystem (Composer, Laravel, Symfony, PHPUnit) and established standards. Real-world usage: PHP powers a huge share of the web (WordPress alone runs an immense proportion of sites), modern frameworks appreciated by developers (Laravel) attract new developers, and job demand stays strong. Node.js, Python and PHP are not "replacements" but alternatives with different strengths — for pragmatic web work, PHP remains an excellent choice.

What is the concrete difference between PHP (server) and JavaScript (browser), and why does it matter?

Two complementary worlds. CLIENT side (browser): HTML, CSS and JavaScript run on the user's machine; client JS code is visible. SERVER side (remote machine): PHP runs the sensitive logic (forms, database, authentication, business rules) and generates the pages; PHP code is never sent to the browser, only its HTML result is. Why it matters: (1) SECURITY — the server is controlled by you, the client is not; sensitive operations must be server-side, and you must never trust the client (a JavaScript validation must be re-checked server-side — section 3.4). (2) ACCESS to resources — the server reaches the database and files, not the browser. (3) PERSONALIZATION — PHP generates different pages depending on the user and the data. Riad's picture: the server is the "kitchen", the client the "dining room".

Check your understanding

Where does PHP code run?

Additional resources (optional, to go further)

Level 0 examFresh, harder questions to test what you've learned