PHP
Articles about PHP by topic. New to the language? Start with the basics or the course.
Start here
Basics
PHP basics
What the language is, where it is used and what else it can do.
Open
Course
PHP course: zero to hero
PHP 8.5 lesson by lesson: language basics, OOP, web, quality tools and capstone projects.
Open
Functions
Built-in functions of PHP 8.5
Every built-in function on its own page: signature, parameters, return value and an example.
Open
Versions
PHP versions: history in brief
What each major version changed, with details on PHP 8.0 and PHP 8.5.
Open
Language
Arrays
Arrays in PHP
How to create an array and read its elements.
Open
Comments
Comments in PHP
One-line and multi-line comments.
Open
Ternary
Ternary operator
A short if-else in one expression.
Open
OOP
OOP in PHP
Classes, objects, constructors, visibility and static members.
Open
Namespaces
Namespaces in PHP
One short class name, many classes: namespace, use and aliases.
Open
require
require and include
require, require_once, include, include_once: differences, traps and a safe-include checklist.
Open
External
Call a function from another file
How to use a function defined in another PHP file.
Open
Dedup
Deduplication in PHP
array_unique, require_once, function_exists guards, DISTINCT and UNIQUE.
Open
Pitfalls
Flat pair arrays: three pitfalls
What goes wrong with a flat [url, title] array and how to guard against it.
Open
Dates, numbers and data
DateTime
Date and time in PHP
How to print date and time in different formats.
Open
Timezones
Several timezones on one page
How to show the time of several timezones at once.
Open
Dates
Compare two dates
How to find out which of two dates is earlier.
Open
random_int
Unique random numbers
How to generate random numbers that do not repeat.
Open
json_decode
json_decode
How to turn a JSON string into PHP arrays and objects.
Open
Web
Cookies
Cookies
How to set, read and delete cookies, with examples.
Open
Sessions
PHP sessions
How sessions work and how to keep data between requests.
Open
Auth
Authentication and authorization
How to authenticate users and services in PHP.
Open
Databases
Databases with PHP
How to connect to a database and run queries.
Open
REST API
REST API requests
How to send requests to a REST API from PHP.
Open
URL
Insert a variable into a link
How to put the value of a variable into a URL.
Open
User-Agent
HTTP_USER_AGENT
How to find out the User-Agent of a visitor.
Open
Screen
Screen width with PHP
What PHP can and cannot tell about the screen of a visitor.
Open
.htaccess
Rules in .htaccess
Redirect, RedirectMatch and RewriteRule: which rules are safe on which server.
Open
Errors and tools
Errors
PHP errors: case studies
Real debugging cases: a menu that disappeared, a live page cut short.
Open
Chunk
Premature end of chunk coded message body
Why the "closing chunk expected" error appears.
Open
Linters
PHP linters we use
php -l, PHPCS, PHPCBF, PHPStan and Psalm on this site.
Open
Frameworks
Laravel
Laravel
What Laravel is and a course of 50 lessons.
Open
Symfony
Symfony
What Symfony is and a course of 50 lessons.
Open