Ever needed to call the same function with different number of parameters? Easy right, just use default values:
But what if you want to make the first parameter optional?
Here’s a simple technique for doing so it in a transparent way.
(more…)
Ever needed to call the same function with different number of parameters? Easy right, just use default values:
But what if you want to make the first parameter optional?
Here’s a simple technique for doing so it in a transparent way.
(more…)
We have shuffle() to reorder a numeric array, we have array_rand() to randomly pick a specific number of values from an array but there’s no built-in command for shuffling an associative array. After having seen a few pretty bad solutions I decided to offer my own.
I was shocked to find a weakness in my authentication library today. It was possible to get around the password check if you knew the username. All you had to do was to enter 00 as the password. Or you just entered 00 as the username too and you got authenticated as the first user.
(more…)
All right, this isn’t exactly a rocket science, it’s just something I use and find very handy.
We all develop (and test) on one computer and deploy to a different computer to make the changes live. Having to run the application in two different environments brings a challenge of using different configuration based on where the application runs.
(more…)
There’s a number of functions out there for calculating the length of time in months but they only provide integer results. MySQL can do it too, for instance. But what if you need to get a precise number?
2008-11-15 minus 2008-10-01 can’t be one if you’re calculating rent. It must be 1.466…