PHP flashcards
The server language behind WordPress and a huge share of the web.
What is PHP, in one plain sentence?
PHP is a programming language that runs on a web and builds the web page a visitor asks for, often using data from a .
Tap to turn over. Swipe right if you know it, left to see it again.
What you will learn
Start from zero
- What PHP is and why it exists4 cards
- Key words4 cards
- Getting ready3 cards
Core basics
- Running PHP2 cards
- Variables and strings3 cards
- Control flow2 cards
- Functions2 cards
- Arrays3 cards
- Forms and requests2 cards
- Classes2 cards
Next steps
- Modern types and design4 cards
- Composer and autoloading2 cards
- Databases2 cards
- Security3 cards
- Building APIs2 cards
- Testing and quality3 cards
Go deeper
- Engine and performance5 cards
- Memory and internals2 cards
- Concurrency and long-running PHP2 cards
- Security in depth3 cards
- Modern PHP features3 cards
- Production and upgrades2 cards
Final test and certificate
10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.
Take the final testAbout these cards
- Reviewed 26 October 2026
- CoversPHP 8.5PHP 8.4
Checked against
PHP at a glance
PHP is a programming language that runs on web servers to build pages and APIs, and it powers WordPress and a large part of the web.
Like a restaurant kitchen behind the counter: the visitor orders a page, PHP cooks it fresh on the server with the right data, and sends back a finished plate of HTML.
Words you will meet
- Server
- A computer that waits for requests and sends back web pages
- Request
- A message from a browser asking the server for a page or data
- Variable
- A named box that holds a value; in PHP its name starts with
$ - Function
- A named set of steps that takes inputs and gives back a result
- Array
- A list or a set of labelled values kept in one variable
- Class
- A blueprint for a kind of thing, like a customer or an order
- Database
- An organised store of data, like customers and orders, that PHP can read and write
- Composer
- PHP's tool that downloads ready-made packages for your project
The steps
- 1. Start from zero (11 cards): What PHP is, how a page is served and the words you need.
- 2. Core basics (16 cards): Running PHP, types, strings, control flow, functions, arrays, forms and classes.
- 3. Next steps (16 cards): Enums, property hooks, Composer, PDO, security, JSON APIs, testing and PHP 8.5.
- 4. Go deeper (17 cards): Request model, OPcache, FPM tuning, memory, fibers, queues, security and upgrades.
All 11 cards in Start from zero
- What is PHP, in one plain sentence?
- PHP is a programming language that runs on a web server and builds the web page a visitor asks for, often using data from a database.
- Why was PHP created?
- In 1994 Rasmus Lerdorf wrote small tools to track visits to his home page. They grew into PHP, a simple way to mix code with HTML so pages could change for each visitor.
- Where do you meet PHP in daily life?
- Blogs and news sites on WordPress, many online shops (WooCommerce, Magento), Wikipedia, and countless school, clinic and small business websites.
- What happens when you open a PHP page?
- Your browser sends a request. The server runs the PHP code, which may read a database, and sends back plain HTML. You never see the PHP itself.
- What is a server, and what is a request?
- A server is a computer that waits for visitors. A request is a visitor's message, like 'show me the cart page'. PHP answers each request.
- Why do PHP variables start with
$? - The
$marks a named box, like$nameor$total. It makes variables easy to spot inside text and HTML. - What is an array in PHP?
- One box holding many values: a simple list like a shopping list, or labelled values like a contact card with
nameandphone. - What is Composer?
- PHP's helper that downloads and updates ready-made packages, like a PDF maker or an email sender, so you do not write them yourself.
- What do you need before you start PHP?
- Basic HTML helps a lot. Install PHP (or a bundle with a web server and database), any code editor, and you can run a page with PHP's built-in server.
- What does a first PHP page look like?
- PHP code goes between
<?phpand?>inside an HTML page.echosends text into the page. - After this topic, what will you be able to do?
- Build dynamic pages and APIs, work safely with forms and databases, read WordPress and Laravel code, and handle PHP interview questions.
PHP cheatsheet
Run and tools
php -S localhost:8000 -t publicBuilt-in dev serverphp -l file.phpSyntax checkphp -mList loaded extensionscomposer require vendor/pkgAdd a packagecomposer install --no-dev -oProduction installcomposer auditCheck for known vulnerabilitiesvendor/bin/phpunitRun tests
Syntax
declare(strict_types=1);No silent type conversion$a ?? $defaultFallback if null or missing$a?->bNull-safe callmatch ($x) { 1, 2 => 'a', default => 'b' }Strict, returning switchfn($x) => $x * 2Arrow functionstrlen(...)First-class callable$x |> trim(...) |> strtoupper(...)Pipe operator (8.5)
Arrays
$list[] = $xAppendarray_map(fn, $a)Transform eacharray_filter($a, fn)Keep matchesusort($a, fn($x, $y) => $x <=> $y)Sort by rulein_array($x, $a, true)Strict containsarray_find / array_any / array_allSearch helpers (8.4)[...$a, ...$b]Merge with spread
Security
htmlspecialchars($s)Escape output for HTML$pdo->prepare(...)->execute([...])Safe SQLpassword_hash($p, PASSWORD_DEFAULT)Store a passwordpassword_verify($p, $hash)Check a passwordbin2hex(random_bytes(32))Secure random tokenhash_equals($known, $given)Timing-safe compare
Classes
public function __construct(private int $x) {}Constructor promotionpublic readonly string $idWrite-once propertypublic private(set) string $sPublic read, private write (8.4)enum Status: string { case Paid = 'paid'; }Backed enumStatus::tryFrom($v)Enum from value or nullclone($obj, ['x' => 1])Copy with changes (8.5)