Skip to content
Learn Netverks

Lesson

Step 17/36 47% through track

superglobals-intro

Introduction to superglobals

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
intermediate

This lesson

An orientation to the PHP track—how the server playground works, core vocabulary, and what you will practice next.

You need a clear map of the PHP track so HTTP, requests, and server execution do not feel like magic.

You will apply Introduction to superglobals in contexts like: LAMP/LEMP stacks, Laravel apps, WordPress themes/plugins, and shared hosting.

Write PHP in the editor and click Run on server—the dev runner executes your script and returns stdout/stderr (set LEARNING_RUNNER_ENABLED=true locally). Also read the interview prep blocks.

After HTML fundamentals and basic programming concepts—before or alongside SQL.

Superglobals are built-in arrays available in every scope: $_GET, $_POST, $_SERVER, $_SESSION, $_COOKIE, $_FILES, $_ENV. They mirror HTTP input and server metadata.

Common superglobals

  • $_GET — query string parameters (?page=2)
  • $_POST — form body fields (application/x-www-form-urlencoded or multipart)
  • $_SERVER — request method, URI, headers (as HTTP_* keys)
  • $_SESSION — server-side session bag after session_start()

Playground simulation

The runner may not populate real superglobals. Treat sample arrays as stand-ins—the access pattern is identical:

$_GET = ['id' => '5']; // simulated
$id = (int) ($_GET['id'] ?? 0);

Security mindset

Never trust superglobal values. Validate, cast, and use prepared statements for database work. Escape on output.

Important interview questions and answers

  1. Q: GET vs POST superglobals?
    A: $_GET from query string; $_POST from request body—method choice affects caching, bookmarks, and size limits.
  2. Q: Why are they called superglobals?
    A: They are always available without global

Self-check

  1. Which superglobal holds REQUEST_METHOD?
  2. Why cast $_GET['id'] to int?

Tip: Treat every superglobal value as untrusted—validate, cast, and never concatenate raw input into SQL.

Interview prep

Which superglobal for form POST fields?

$_POST holds body fields from POST requests; validate with filter_input or explicit checks before use.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • $_GET trust level?
  • Which global surprises you?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump