Tag: php
Caching Strategies
PHP 7.0+
Patterns for when and how to store and invalidate cached data — cache-aside, write-through, write-behind, and read-through each make different trade-offs between consistency, complexity, and performance.
3mo ago
Performance intermediate
Capture Groups & Backreferences
PHP 5.3+
4
Parentheses in a regex pattern create capture groups that store matched substrings for extraction or reuse — backreferences let you match the same text again later in the pattern or replacement string.
3mo ago
Regex beginner
Cardinality in Observability
PHP 7.0+
The number of unique combinations of label values in a metric — high cardinality (millions of unique label combinations) causes memory exhaustion in time-series databases and is the most common observability scaling problem.
3mo ago
Observability intermediate
Catastrophic Backtracking
PHP 5.3+
2
A regex engine failure mode where certain patterns combined with specific inputs cause exponential backtracking, making the match take seconds or minutes — a common denial-of-service vector called ReDoS.
3mo ago
Regex intermediate
Collation & Locale-Aware Sorting
PHP 7.0+
1
Locale-specific rules for ordering strings alphabetically — determining that ä sorts near a in German but after z in traditional Swedish, and that sorting must not rely on byte values for Unicode text.
3mo ago
i18n intermediate
CORS — Cross-Origin Resource Sharing
PHP 7.0+
A browser security mechanism that blocks JavaScript from making HTTP requests to a different origin — PHP APIs must send specific headers to allow cross-origin requests from permitted frontend origins.
3mo ago
Security intermediate
CQRS Pattern
PHP 7.0+
Command Query Responsibility Segregation — separating the write model (commands that change state) from the read model (queries that return data), allowing each to be optimised independently.
3mo ago
Messaging advanced
create_function() — The Dynamic Code Smell
PHP 4.0+
8
create_function() created anonymous functions from strings — deprecated PHP 7.2, removed PHP 8. It used eval() internally, risked code injection, and was always replaceable with proper closures.
3mo ago
PHP intermediate
Cross-Version Compatibility Testing
PHP 7.0+
Testing PHP code across multiple versions uses CI matrix builds, phpenv/phpbrew, Docker multi-version setups, and static analysis to catch compatibility issues before deployment.
3mo ago
PHP intermediate
Call to Undefined Function/Method
PHP 4.0+
1
'Call to undefined function' means the function wasn't declared, the file wasn't loaded, or the PHP extension providing it isn't installed.
3mo ago
PHP beginner
callable vs Closure vs First-Class Callable
PHP 7.1+
PHP has three callable forms: loose callable (string/array), typed Closure, and PHP 8.1 first-class callables (strlen(...)) — prefer Closure or first-class callables for type safety.
3mo ago
PHP intermediate
Cannot Redeclare Function/Class Errors
PHP 4.0+
PHP throws a fatal error when a function or class is declared twice in the same request — use autoloading and function_exists() guards to prevent it.
3mo ago
PHP beginner
Circular References & Memory Implications
PHP 5.3+
1
Circular references between objects prevent PHP's reference counting GC from freeing memory — PHP's cycle collector handles them but with overhead.
3mo ago
PHP intermediate
Class Not Found / Autoloader Failures
PHP 5.3+
'Class not found' errors mean the autoloader couldn't locate the class file — usually a namespace mismatch, missing composer install, or PSR-4 misconfiguration.
3mo ago
PHP beginner
Constructor Promotion + readonly Together
PHP 8.1+
PHP 8.1+ allows readonly in constructor promotion: public function __construct(public readonly string $name) — the cleanest way to write immutable value objects.
3mo ago
PHP intermediate
Custom Error Handlers (set_error_handler)
PHP 5.0+
2
set_error_handler() lets you replace PHP's default error handling with a custom callback — essential for logging, alerting, and graceful degradation.
3mo ago
PHP intermediate
Cache-Timing Side-Channel Attacks
PHP 5.6+
Attacks that infer secret information from response time differences — cached responses arrive faster than uncached ones, leaking whether a resource exists or a secret was correct.
3mo ago
Security advanced
Character Encoding
PHP 5.0+
2
How text is stored as bytes — ASCII (128 chars), Latin-1 (256 chars), UTF-8 (1-4 bytes, backwards compatible), and UTF-16 are the key encodings developers encounter.
3mo ago
i18n intermediate
Class Naming Convention
PHP 5.0+
PHP classes must use PascalCase (UpperCamelCase) per PSR-1 — each word capitalised, no underscores, descriptive nouns or noun phrases.
3mo ago
Style beginner
Column-Level Encryption
PHP 7.1+
1
Encrypting sensitive database columns (SSN, credit card, medical data) — application holds the key; database never sees plaintext; breach exposes only ciphertext.
3mo ago
Database advanced