The Art of Being Anonymous in PHP This post is a tour of PHP’s nameless constructs: from closures and arrow functions to anonymous classes and non-binding catch blocks. Every day, in most PHP code, things have names. Variables are named, classes have identifiers, functions are called by their name. Though, PHP also offers a rich […]
Renaming Parameters in a method Renaming parameters in a method used to be an innocuous operation: one could do it without impact. Since PHP 8.0, such renaming may break existing calls. With named parameters, not only the method name, but also its parameters are part of the call. And it is a common challenge to […]
PHP Inheritance Challenge: Calling All Ancestors PHP’s object-oriented features are exhaustive and modern, yet sometimes life send you a little challenge: who doesn’t like a surprise? Today we’ll look at a rare inheritance puzzle. In this post, we are calling all ancestors in a class hierarchy. We start with three classes, extending each other in […]
Refactoring Strings to Enums This article describes the journey of refactoring a not-so-old piece of code from using strings to using enumerations. Original Reasons When Exakat was started in 2014, enumerations were not even on the radar. Strings, and sometimes constants, were the obvious solution. As the original concept evolved quickly, strings were used everywhere, […]
All PHP 8.5 hash algorithms Choosing the right hashing algorithm is difficult, balancing the need for security, speed, and reliability. PHP offers a almost 60 built-in hashing options, but not all are created equal : some are industry standards for cryptographic security, while others are optimized for lightning-fast non-cryptographic tasks like caching or checksums; some […]
Convert a string to integer with PHP PHP 8.5 provides a new error message when one tries to convert a string to integer with PHP. The float-string “%s” is not representable as an int, cast occurred This is new with this version, and besides the warning itself, it is not even a changed behavior. It […]
Understanding Relationships Between Classes, Interfaces, Traits, and Enums in PHP Modern PHP offers four major code structures — classes, interfaces, traits, and enums — each with its own purpose and rules. But the real power of PHP comes from how these structures can interact with each other. This page gathers all relations between classes in […]
Infinite loops in PHP Sometimes, they are demonized, and sometimes, they are useful. Infinite loops come in a variety of options in PHP, so let’s put them neatly on a shelf, with all theirs variations. Classic while (true) To make an infinite loop, the most simple is to take a loop, and make it unconditional. […]
Quines for PHP A quine is a piece of code that executes to produce itself. This is a self displaying code. The execution of the code outputs the same source code, before it was executed. No changes happened, and one may run it again, to the same result. While this code curiosity has rare direct […]
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 […]










