Tag: php
A performance anti-pattern where fetching N records triggers N additional queries — one per record — instead of a single JOIN.
2mo ago
database intermediate
Named Arguments (PHP 8.0) PHP 8.0+
PHP 8.0 named arguments let you pass values by parameter name — skipping optional params, self-documenting calls, and enabling out-of-order argument passing.
2mo ago
php beginner
Named Arguments in Attributes PHP 8.1+
PHP 8.1+ allows named arguments inside attribute constructors — #[Route(path: '/home', methods: ['GET'])] — making attribute usage self-documenting.
2mo ago
php intermediate
Null Byte in File Paths (Legacy PHP) PHP 3.0+
Null bytes (%00) in file paths truncated strings at the C level in PHP < 5.3.4 — PHP 5.3.4+ throws a warning, PHP 7 throws ValueError for NUL in paths.
2mo ago
security advanced
Null Coalescing ?? Operator (PHP 7.0) PHP 7.0+
PHP 7.0's ?? operator returns the left side if it exists and isn't null, otherwise the right — replacing isset($x) ? $x : $default with $x ?? $default.
2mo ago
php beginner
Null Reference Errors PHP 5.0+
Errors caused by calling methods or accessing properties on null — PHP's 'Call to a member function X() on null' and JavaScript's 'Cannot read properties of null' are the most common runtime errors in both languages.
2mo ago
php beginner
Named Capture Groups PHP 5.3+
(?P<n>pattern) in PHP/PCRE for self-documenting regex — accessing matches by name instead of positional index.
2mo ago
regex intermediate
nginx + PHP-FPM Production Config PHP 5.0+
The canonical nginx + PHP-FPM setup for PHP production — nginx handles static files and slow clients, PHP-FPM runs PHP via FastCGI, with proper timeout, buffer, and security settings.
2mo ago
devops intermediate
Null Coalescing Operator Not Used PHP 7.0+
Using isset() + ternary or if/else chains when the null coalescing operator (??) or null coalescing assignment (??=) would be cleaner and more idiomatic.
2mo ago
style beginner
N+1 Problem in Doctrine & Eloquent PHP 7.0+
Accidentally issuing one query per related entity instead of one JOIN — the most common ORM performance pitfall, solved by eager loading.
2mo ago
performance intermediate
Named Arguments (PHP 8.0) PHP 8.0+
Pass arguments to a function by parameter name rather than position, improving readability and allowing optional parameters to be skipped.
2mo ago
php beginner
Named Arguments in Built-in PHP Functions PHP 8.0+
PHP 8.0 named arguments work with built-in functions — enabling readable calls to functions with many optional parameters like array_slice().
2mo ago
php intermediate
Named Arguments with Spread Operator PHP 8.1+
Combining PHP 8.0 named arguments with the ... spread operator to unpack associative arrays as named parameters.
2mo ago
php intermediate
Named Constructor Pattern PHP 5.0+
Static factory methods with descriptive names that replace overloaded constructors — making object creation intent clear when multiple creation paths exist.
2mo ago
php intermediate
Naming Conventions PHP 5.0+
Consistent naming rules for classes, methods, variables, and constants that make code self-documenting and predictable.
2mo ago
style beginner
never Return Type (PHP 8.1) PHP 8.1+
Declares that a function never returns normally — it always throws an exception or calls exit(), helping static analysers prove code paths.
2mo ago
php intermediate
never Return Type (PHP 8.1) PHP 8.1+
Declaring a function's return type as never signals it always throws or exits — enabling static analysers to prune unreachable code branches.
2mo ago
php intermediate
Null Coalescing Operator (??) PHP 7.0+
Returns the left operand if it exists and is not null, otherwise the right — cleaner than isset() ternary chains.
2mo ago
php beginner
Nullable Types (?Type) PHP 7.1+
Declaring a type as ?Type allows either a value of that type or null — shorthand for Type|null.
2mo ago
php beginner
Nullsafe Operator (?->) PHP 8.0+
Chains method calls and property accesses on potentially-null objects without nested null checks; returns null on the first null encounter.
2mo ago
php beginner