There are two moments in the life cycle of a project where you can apply a long known best practice : « write test first, then the code ». The first one is when you start writing the code, and you have some time. The second is when the current architecture of the software has reached its maximal […]
Confusing variable names Did you ever meet that awful situation, where you try to understand why the SQL query fails, until you realize that $res and $req are simply too confusing ? There are confusing variable names, notably those that are one letter close from each other. Problems ranges from $data and $date in the same […]
Find private properties in my PHP It is always good to use the lowest visibility possible for a class member, and only relax the constraint when it is really needed. This is probably a old adage, shared with other programming languages, and one that I’m trying to apply more and more. Public properties will act as […]
The art of PHP callback PHP callback are functions that may be called dynamically by PHP. They are used by native functions such as array_map, usort, preg_replace_callback, etc. Here is a reminder of the various ways to create a callback function in PHP, and use it with the native functions. String functions Strings are the […]