After a long string of delays, PHP 5.3 is finally out. On the course of last 2 years, I was pretty sure a number of times that it will happen next month the latest, but there always were good reasons to postpone it. Now finally it’s officially out. I think it’s a huge step for PHP. Download it and try it!
Some major new features in 5.3:
- Namespaces! They didn’t end up exactly as I thought they would but they are a major feature PHP was missing for a long time, and I’m very curious to see how it works out in big projects.
- Closures and anonymous functions! PHP now has first-class functions, and you can do all kinds of crazy stuff with it. Or just make your code easier to read and maintain 🙂
- Garbage collection. PHP engine, being refcount-based, always has had a slight problem with reference loops. Even though usually it was not a big issue since at the end of the request everything is cleaned up, for long-running PHP applications not based on short request pattern it became a problem. Not anymore – now the engine knows to clean up such loops.
- Late static binding – it’s somewhat exotic thing for people that never encountered it, but was very burning issue for people that did need it. Basically, when class Foo extends class Bar, and the method func() defined in Foo is called as Bar::func(), there was no way to distinguish it from Foo::func(). Now there is. This allows to implement all kinds of cool patterns like ActiveRecord.
- Intl extension in core – lots of functions to allow you to internationalize your application.
- Phar in core – now you can pack all the application in one neat file and still be able to run it!
Also in 5.3:
- Nowdocs – same as heredocs, but doesn’t parse variables. Excellent feature for somebody that wants to include bing chunk of text into the script which can happen to have $’s etc. in it.
- ?: shortcut. That’s simple – $a?:$b is $a if $a is true, otherwise it’s $b.
- goto. Yes, I know. But now we have it too. Deal with it. 🙂
- mysqlnd – native PHP-specific mysql driver.
Last but definitely not least – tons of performance improvements, bug fixes, etc. Download it today! 🙂