PHP Fundamentals
PHP is a server-side scripting language designed for web development. It runs on a web server, processes requests, and produces HTML that a browser displays. Most of the web's content management systems and many large-scale applications use PHP as their primary language.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: PHP Fundamentals
PHP is the server-side language that waits behind a web server, receives a request, does some work, and sends back HTML or JSON. The browser gets the finished result, not the PHP code. This arrangement has been serving the web since PHP began as a collection of CGI scripts in 1994, which is an impressively durable career for something that started by counting page visits.
The central idea is the request lifecycle. A browser asks, the web server passes the request to PHP, PHP runs from start to finish, and the server returns the output. Then the request's memory goes away. Each request starts with a blank slate, so anything that must outlive it belongs in a database, cache, session store, or queue. PHP is not forgetful; it is very disciplined about putting yesterday's paperwork in the shredder.
The first surprise is that dynamic typing does not mean modern PHP has no opinions about types. Variables remain flexible, but functions, return values, and class properties can carry declarations that the runtime enforces. PHP 8 also brings union types, enums, readonly properties, fibers, and other ways to describe program structure. These are not decorations for a code review. They make the shape of input and output visible where it matters.
A second useful landmark is Composer, the dependency manager. It records packages in composer.json, pins resolved versions in composer.lock, and generates an autoloader for classes. That removes a great deal of manual file inclusion, although it does not remove the need to test a real request or verify the environment. Composer organizes the library cupboard. It cannot tell whether somebody left the plumbing disconnected.
The ecosystem is broad enough to be confusing at first. Frameworks such as Laravel and Symfony add routing, templates, database access, and testing structure. WordPress, Drupal, and other content platforms place PHP inside larger publishing and commerce systems. PHP-FIG's PSRs, interoperability standards, help libraries cooperate. The language also carries older habits, so current PHP documentation is a safer guide than a tutorial with an impressive vintage.
Read the Intro when the request lifecycle and the language's limits need a fuller explanation. Use Slides for the map from browser to web server to PHP to response. Keep the Cheatsheet nearby for syntax, PDO prepared statements, Composer commands, and security details. The Practice Reference and exercise turn that map into a small running endpoint. Field Notes covers the operational traps that appear after the first successful request, which is when the paperwork begins to develop opinions.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.php.net/manual/en/introduction.php
Supports
- PHP as a server-side scripting language focused on web development
- Three areas of use (server-side, command-line, desktop)
- Shared-nothing request lifecycle
- PHP running on a web server producing output sent to the browser
- https://www.php.net/manual/en/history.php.php
Supports
- Creation by Rasmus Lerdorf in 1994
- Evolution from CGI scripts to a full programming language
- Community-driven development history
- https://www.php.net/manual/en/langref.php
Supports
- PHP syntax (semicolons, curly braces, dollar-sign variables)
- Control structures (if, for, foreach, while, match)
- Functions, closures, and arrow functions
- C, Java, and Perl syntax heritage
- https://www.php.net/manual/en/language.types.declarations.php
Supports
- Scalar type declarations introduced in PHP 7.0
- Return type declarations
- Union types (8.0), intersection types (8.1), DNF types (8.2)
- Nullable types and void/never return types
- Runtime enforcement of type declarations
- https://www.php.net/manual/en/language.variables.basics.php
Supports
- Dollar-sign prefix for all variables
- Case sensitivity of variable names
- Dynamic typing by default
- https://www.php.net/manual/en/language.oop5.php
Supports
- Classes, interfaces, traits, abstract classes
- Single inheritance, multiple interface implementation
- Visibility modifiers (public, protected, private)
- Constructor promotion, readonly properties
- https://www.php.net/manual/en/language.enumerations.php
Supports
- Enums added in PHP 8.1
- Backed enums with string or int values
- Type-safe fixed value sets
- Quiz answer about enums as the correct feature for fixed statuses
- https://www.php.net/manual/en/language.fibers.php
Supports
- Fibers added in PHP 8.1
- Cooperative multitasking within a single thread
- Suspend and resume execution model
- Not parallel or multi-threaded execution
- https://www.php.net/manual/en/book.pdo.php
Supports
- PDO as a database abstraction layer
- Prepared statements preventing SQL injection
- Support for MySQL, PostgreSQL, SQLite
- Error mode configuration
- https://www.php.net/manual/en/pdo.prepared-statements.php
Supports
- Prepared statements separating query structure from data
- SQL injection prevention mechanism
- Quiz answer about why prepared statements prevent injection
- https://www.php.net/manual/en/book.opcache.php
Supports
- OPcache storing compiled bytecode
- Elimination of repeated parsing and compilation
- Bundled with PHP since 5.5
- https://www.php.net/manual/en/features.connection-handling.php
Supports
- Script termination and resource cleanup at request end
- Shared-nothing request model
- https://www.php.net/releases/8.4/en.php
Supports
- PHP 8.4 released November 2024
- Property hooks and asymmetric visibility
- Updated DOM API and performance improvements
- https://getcomposer.org/doc/00-intro.md
Supports
- Composer as the standard PHP dependency manager
- Package resolution from Packagist
- Class autoloading generation
- Lock file for reproducible installs
- https://www.php-fig.org/psr/
Supports
- PSR-4 autoloading standard
- PSR-7 HTTP message interfaces
- PSR-12 coding style
- PSR-15 middleware
- Interoperability between PHP libraries and frameworks
- https://www.php-fig.org/psr/psr-4/
Supports
- Class-to-file mapping by namespace prefix
- Composer implementation of PSR-4
- Quiz answer about PSR-4 as the autoloading standard
- https://phpstan.org/user-guide/getting-started
Supports
- Static analysis finding type errors without execution
- Rule levels for progressive strictness
- Quiz answer about static analysis as the tool category for pre-runtime type checking
- https://psalm.dev/
Supports
- Alternative static analysis tool for PHP
- Type inference and error detection
- https://w3techs.com/technologies/details/pl-php
Supports
- PHP usage share among server-side languages (approximately 75 percent)
- WordPress market share (over 40 percent of all websites)
- https://www.php.net/releases/8.1/en.php
Supports
- PHP 8.1 release and language features including enums and fibers
- https://www.php.net/releases/8.2/en.php
Supports
- PHP 8.2 release and language features including readonly classes and DNF types
- https://www.php.net/releases/8.3/en.php
Supports
- PHP 8.3 release and language features including typed class constants and json_validate
- https://www.php.net/supported-versions.php
Supports
- PHP release-branch support windows
- https://medium.com/vimeo-engineering-blog/its-not-legacy-code-it-s-php-1f0ee0462580
Supports
- Vimeo's PHP 5.4 to PHP 7 modernization and use of static analysis for large-scale changes
- https://laravel.com/
Supports
- Laravel as a PHP framework with routing, application structure, and Composer-based installation
- https://symfony.com/
Supports
- Symfony components and full-stack framework for PHP applications
- https://wordpress.org/
Supports
- WordPress as an open-source PHP publishing platform
- https://www.drupal.org/
Supports
- Drupal as an open-source PHP content management platform
- https://www.slimframework.com/
Supports
- Slim as a PHP framework for HTTP request and response handling
- https://www.jetbrains.com/phpstorm/
Supports
- PhpStorm features for PHP development, code inspection, and debugging
