PHP 5.3.0 Released

Today the latest stable version of PHP was announced, PHP 5.3.0.

Go download and play with the new features available such as namespaces, LSB, anonymous functions and closures along with many more bug fixes, additions and improvements.

My favourite addition at the moment is the improvements made to the DateTime extension with new classes such as DatePeriod (for iterating over dates/times) and DateInterval and additions to the DateTime class such as DateTime::createFromFormat and DateTime::add (and sub).

The anonymous functions will also be very useful where one might previously use create_function (or a normal non-anonymous function) in particular for callbacks to other functions/methods.

<?php
echo preg_replace_callback('/[A-Z]/', function ($match) {
    return str_rot13($match[0]);
}, 'Uello Jorld!');
?>

So, download it and have an explore. :)

XPath for CSS classes

I was playing around with YQL today and was scraping a HTML document (no details, that’s not the point of this blog entry). Part of the processes meant that I needed to check for a specific CSS class attached to some elements.

Easy enough, XPath contains (pardon the pun, see later) some nifty functions which can act on nodes and their values to be used in conditional checks like I needed. I’ve been using the technique outlined in this post for a very long while (usually with XPath in PHP) and originally stumbled upon the basic idea from How to map CSS selectors to XPath queries (Thanks ever so much!) Today’s use of it prompted this blog post.

Click here to read more »

Parsing Dates with DateTime

This post comes on the back of a number of forum posts I’ve seen floating around where the Original Poster (OP) asks a question along the lines of, “I have a date in dd/mm/yyy format, how can I work with it?

The problem is that the most common way of parsing strings into a more usable format (Unix timestamp) is to use strtotime(). However, this function does not like dd/mm/yyyy formatted strings and will at best parse the string as mm/dd/yyyy and at worst return FALSE (if it could not parse the date string as mm/dd/yyyy).

Click here to read more »

Joined the PHP Documentation Team

PHP logo This is just a very short update to announce quietly that I recently joined the team of folks working on the PHP documentation. It’s another step towards giving a little something back to the PHP community by adding to and updating the constantly evolving docs which have helped me along for so many years. Incidentally, my first commit was too large to be sent out to the mailing list tracking the changes to the documentation. Oops!

Kohana 2.3.3 (and 2.3.4) Released

Recently the guys over at Kohana flicked the switch on the latest release: version 2.3.3. There have been many changes and improvements along the way (see the 2.3.3 changelog for details). I just want to send a big thanks to everyone who donates their time into developing the framework that I use all of the time. Thanks!

This will be the last version on the 2.3 branch with forward movement pushing ahead with 2.4 (coming with new and improved features) and of course Kohana 3 is also being very actively developed.

Update Only a couple of days later, 2.3.4 has also been unleashed to the public. :)