Tag: php
each() & list() — Deprecated Iteration
PHP 3.0+
each() was deprecated in PHP 7.2 and removed in PHP 8 — replace while(list($k,$v)=each($arr)) with foreach. list() itself is still valid as [] destructuring.
3mo ago
PHP beginner
Elasticsearch Fundamentals
PHP 7.0+
A distributed search and analytics engine built on Lucene — storing documents as JSON, indexing them automatically, and providing a REST API for full-text search, aggregations, and real-time analytics.
3mo ago
Search intermediate
Engine Exceptions — Error Hierarchy (PHP 7.0)
PHP 7.0+
PHP 7.0 made fatal engine errors catchable as Error subclasses — TypeError, ParseError, ArithmeticError, DivisionByZeroError — via the shared Throwable interface.
3mo ago
PHP intermediate
Enums — First-Class Enumerations (PHP 8.1)
PHP 8.1+
PHP 8.1 native enums replace class constant hacks — providing type-safe, enumerable, matchable values with optional backing values (: string or : int).
3mo ago
PHP intermediate
ereg() / eregi() — POSIX Regex Removed in PHP 7
PHP 3.0+
ereg() and eregi() were POSIX regex functions removed in PHP 7.0 — replace with preg_match() (PCRE) which is faster, more powerful, and the standard since PHP 4.
3mo ago
PHP beginner
Error Logging
PHP 4.0+
2
Recording application errors, exceptions, and diagnostic information to persistent storage — essential for diagnosing production issues where display_errors must be off and errors are invisible to users.
3mo ago
PHP beginner
Error Reporting & Display
PHP 4.0+
1
PHP's error_reporting level and display_errors directive control which errors are shown and where — development needs E_ALL with display on; production needs E_ALL with display off and logging on.
3mo ago
PHP beginner
Exception Handling Introduced (PHP 5)
PHP 5.0+
PHP 5 introduced try/catch/finally and the Exception class — replacing PHP 4's procedural error handling with structured exception-based patterns.
3mo ago
PHP beginner
Enum::cases() & Enum from()/tryFrom()
PHP 8.1+
Backed enums provide from() (throws on miss) and tryFrom() (returns null) for value lookup, plus cases() to get all cases — essential for forms and validation.
3mo ago
PHP intermediate
Enums Implementing Interfaces
PHP 8.1+
PHP 8.1 enums can implement interfaces, allowing them to be used wherever an interface is expected — enabling polymorphic enum-based dispatch.
3mo ago
PHP intermediate
Exception Hierarchy (Throwable, Error, Exception)
PHP 7.0+
1
PHP 7+ unified exceptions and fatal errors under the Throwable interface — catch Throwable to handle both Error and Exception in one block.
3mo ago
PHP intermediate
extract() Security Risk
PHP 4.0+
extract() creates variables from an array in the current scope — using it on user input ($_POST, $_GET) allows attackers to overwrite any local variable.
3mo ago
Security intermediate
Elvis Operator Not Used
PHP 5.3+
Writing $x ? $x : $y instead of $x ?: $y — the Elvis operator (?:) returns the left operand if truthy, otherwise the right, eliminating the repeated expression.
3mo ago
Style beginner
Environment Variables
PHP 5.0+
1
Key-value pairs inherited by child processes — the standard way to pass configuration, credentials, and runtime settings to PHP applications without hardcoding.
3mo ago
Linux intermediate
Error Suppression Operator (@)
PHP 5.0+
Prefixing a PHP expression with @ silently suppresses all errors and warnings it generates — hiding bugs instead of handling them.
3mo ago
Code Quality beginner
Event Bus Patterns
PHP 7.0+
Patterns for routing events between publishers and subscribers — in-process event buses (Symfony EventDispatcher), message broker buses (RabbitMQ, Kafka), and hybrid architectures.
3mo ago
Messaging intermediate
Excessive Blank Lines
PHP 5.0+
Multiple consecutive blank lines within a function or between statements — adding visual noise without improving readability.
3mo ago
Style beginner
Enum Methods, Interfaces & Constants (PHP 8.1)
PHP 8.1+
PHP 8.1 enums support methods, interface implementation, constants, and static factory methods — making them full-featured types, not just value lists.
3mo ago
PHP intermediate
Enums (PHP 8.1)
PHP 8.1+
3
Native enumerations providing type-safe named constants that replace class-constant patterns and stringly-typed values.
3mo ago
PHP intermediate
Error Handling in PHP
PHP 5.0+
2
Uncaught errors and verbose error output expose stack traces, file paths, and credentials to attackers.
CWE-209 OWASP A9:2021
3mo ago
PHP beginner
5.3