Lazy class constants in PHP

Lazy class constants in PHP

Lazy class constants in PHP: fast by design, sometimes surprising PHP has class constant, which are named literals. It also supports static constant expressions, where the value is not always a literal. Rather, it’s an expression that PHP doesn’t evaluate immediately. PHP evaluates it the first time the code needs it. This is the concept […]

Tracing a PHP CLI application with filo

Tracing a PHP CLI application with filo

Tracing a PHP CLI application with filo filo is a zero-extension PHP call tracer. No PECL module, no Xdebug session: it registers a file:// stream wrapper and rewrites your code’s AST on the way in, so every function entry and exit gets timed. Your files on disk are never touched: instrumented copies live in a […]

Adding the last types to PHP code in 2026

Adding the last types to PHP code

Adding the last types to PHP code 2026 update note: This is an update of the original 2022 article, with annotations added locally to flag what’s changed in the PHP language since: mainly PHP 8.4’s property hooks and asymmetric visibility, which give native answers to several problems the article works around by hand. Adding the […]

Hidden Traps with Chained Assignments

Hidden Traps with Chained Assignments

Hidden Traps with Chained Assignments If you’ve been writing PHP for a while, you’ve almost certainly written a few chained assignments yourself. It’s that neat, concise trick where you initialize multiple variables or properties on a single line: <?php $count = $total = $limit = 0; ?> It looks clean. It feels efficient. It’s the […]

php-typos: a fast spellchecker for PHP codebases (Tool Review)

php-typos: A Fast Spellchecker for PHP Codebases (Tool Review) There’s a particular kind of embarrassment reserved for the typo that ships to production. A recievePayment() method. A config key spelled treshold. A comment that confidently explains the “lenght” of an array. None of it breaks anything, all of it makes the codebase look a little […]

The Empty String in PHP: One Value, Too Many Jobs

The Empty String In PHP

The Empty String in PHP: One Value, Too Many Jobs The humble empty string “” is everywhere. It’s the quiet default, the silent failure signal or the silent success signal, the lazy cast, the natural accumulator. Behind the obvious simplicity of the empty string in PHP lies a surprising amount of overloaded meanings, which leads […]

PHP parentheses usage

The Required, The Optional, The Useless, and The Weird: of In PHP, parentheses () aren’t just punctuation : they play different roles depending on where and how they’re used. Some are compulsory, others are optional, and a few are just useless clutter. And then, there’s the weird one: (cast). Let’s review all PHP parentheses usages […]

New error messages in PHP 8.4

New PHP error messages in PHP 8.4 The upcoming PHP 8.4 is bringing new errors messages, and, also, removing some of them. The new messages originate from new features, deprecated ones, removed ones, and extra checks throughout the source code. Let’s review the new PHP error messages in PHP 8.4 and get our code ready […]

Changed Behaviors in PHP

Changed Behavior in PHP

The Ultimate Guide to Navigating PHP Features Updates As PHP evolves, so do the language’s features, functionalities. And even the nuances in its behaviors. Yes, there are changed behaviors in PHP. They range from syntax changes to change in behavior of certain functions. And it can be overwhelming to keep track of how each new […]

Array, classes and anonymous classes memory usage

Printing press characters in their boxes

I have been working with a code base that uses a lot of arrays as hashes recently. This is a style that I am confortable with, as I do enjoy PHP arrays : flexible, powerful, versatile. Who don’t like them? Yet, I keep hearing that classes are more memory efficient than arrays. Yet, I still […]