|
Thursday, 1 November 2007
I thought I’d share with you a PHP class I found useful lately. I had to take a comma-delimited text file and turn it into an XML text stream. With the ubiquity of XML these days, you might find it useful too, if you dabble in PHP software development.
Read more >>
Wednesday, 4 July 2007
I know that PHP has a lot of functions built right in, some of which are used frequently and
some sparingly. But what about “home made” functions that we’ve created? Which are the most used?
Read more >>
Saturday, 16 June 2007
One of our readers recently observed that we don’t seem to be using any images to draw our barcharts and wondered how it was done.
Read more >>
Tuesday, 5 June 2007
We’ve seen plenty of PHP scripts that rely on the $_SERVER['REMOTE_ADDR'] variable when trying to establish the IP address of the client computer. The problem with this approach is that if your visitor is behind a corporate firewall or proxy, then the above will actually be the IP of the firewall or proxy, not the visitors computer.
Read more >>
Tuesday, 15 May 2007
Here’s the easiest way to output the last day of any month using PHP:
function lastday($month = '', $year = '') {
if (empty($month)) {
$month = date('m');
}
if (empty($year)) {
$year = date('Y');
}
$result = strtotime("{$year}-{$month}-01");
$result = strtotime('-1 second', strtotime('+1 month', $result));
return date('Y-m-d', $result);
}
We found it useful for reporting purposes when filtering data purely for the “current” month but by specifying the month and year arguments, you can use it for any month of any year.
Please note that the output is in IS0 8601 international date format. If you need anything else, modify the last line to suit.
|