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 […]
Recently, I delved into a piece of code that involved a case-insensitive comparison of a character to a specific letter. The code, though straightforward, had room for optimization. Not being a fan of lengthy logical expressions, my curiosity led me to explore ways to make it more concise and potentially faster. What is the fastest […]
Collateral behavior changes with PHP 8.0 switch() PHP 8.0 introduced a modernisation of the comparison between integers and strings. It changes the result of comparisons when a string is compared to an integer. Obviously, it includes comparing 0 and ” (empty string). This means that some comparisons were true in PHP 7, and are not […]
Ensuring a Well-Structured Switch Command in PHP In PHP, the switch statement is a powerful tool for controlling program flow, especially when dealing with multiple conditional branches. However, achieving a clean and efficient switch has its own snags. This post explores essential tips and practices for checking the quality of a ‘switch’ command to ensure […]
New PHP errors messages in PHP 8.3 The upcoming PHP 8.3 is bringing some new errors messages. They originate from new features, deprecated ones, and extra checks on the source code. Let’s review the new PHP error messages in PHP 8.3 and get our code ready for November 2023. Previous review New error messages in […]
Introduction In today’s fast-paced software development landscape, DevOps has become a vital part of ensuring efficient and seamless delivery of applications. While DevOps practices enable collaboration and automation between development and operations teams, maintaining clean and high-quality code remains a challenge. This is especially true for PHP developers, who often encounter difficulties in identifying code […]
14 PHP arguments that are not enough used PHP has a few thousands functions under its belt, and there are even more arguments. And just like for functions, some of those arguments are not often used, while they provide a useful extension to the original behavior of the function. To catchup with them, here are […]
Removing a value in an array, six methods Removing one value is a classic task, and it is quite natural to discover multiple ways to do so. Then, you can choose the one that suits your coding style the best. Usually, alternatives algorithms come with different limitations : speed, memory usage, extensions… In this article, […]
Semantic typing Semantic typing is an old practice, where the name of the parameter would also tell what its type is. It is typing, because a $string is supposed to be typed, and it is semantic, because only the human reader is actually using the meaning : PHP doesn’t really care. The interesting part is […]
Code inventories Code inventories are lists of items iof the same type. It is also the process to making such list. The inventory is meant to provide a complete view over available ressources. Translated to code, PHP or else, it is an auditing process that collects code structures of one type, for further analysis. For […]