November 20, 2007
We are already familiar with namespaces, late static binding and mysqlnd but PHP 5.3 has a lot more cool features. We can find some information about the features of the upcoming PHP version from Johannes SchlÃ¼ter’s (the release manager of PHP 5.3) blog entry and from the PHP Release Management Wiki. Some of the features are interesting only for internals, but there are a lot of great ones for end users too: __callStatic, dynamic static call, OpenID support, improved ini handling, XSLT profiling, SQLite 3 support and more.
Probably you are familiar with PHP’s magic methods. PHP 5.3 introduces a new magic method: __callStatic, which is very similar to __call but it is for static calls. It is cool, we are waiting for the __get, __set etc. counterparts.
1 2 3 4 5 6 7 8 9 10 11
static function __callStatic($method, $arguments)
// $mathod == &qout;bar&qout;...
Dynamic static calls
I think variable variables are one of the most useful things in PHP. In PHP 5.3 there is a new possibility on this area, the following code is possible:
1 2 3 4 5 6 7 8 9
$class = 'bar';
$namespace = 'foo';
You can find here a useful example from Etienne Kneuss, who implemented the patch for this functionality.
Improved ini handling
Jani Taskinen created a patch providing improved ini handling. We can get some insight of how it will be working from the commit message:
- Added “.htaccess” style user-defined php.ini files support for CGI/FastCGI.
- Added support for special [PATH=/opt/httpd/www.example.com/] sections in php.ini. All directives set in these sections will not be able to be overridden in user-defined ini-files or during runtime in the specified path.
- Improved php.ini handling:
- Added better error reporting for syntax errors in php.ini files
- Allowed “ini-variables” to be used almost everywhere ini php.ini files
- Allowed using alphanumeric/variable indexes in “array” ini options
- Fixed get_cfg_var() to be able to return “array” ini options
And we can get some more information from the related php.ini addition:
1 2 3 4 5 6 7 8 9 10 11
+; php.ini Options ;
+; Name for user-defined php.ini (.htaccess) files. Default is &qout;user.ini&qout;
+;user_ini.filename = &qout;user.ini&qout;
+; To disable this feature set this option to empty value
+; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes)
+;user_ini.cache_ttl = 300
In PHP 5.3 the openssl extension will provide high speed Diffie-Hellman support, which is important for OpenID. You can get more information from Dmitry Stogov’s proposal.
getopt() on any platform
As from PHP 5.3 the
getopt() function will be available even on Windows systems, and
getopt() will support
longopts on every system.
E_STRICT will be splitted to
E_STRICT error will mean common bad practices and
E_DEPRECATED will be triggered when you try to use such a language feature which is likely to go away from a later version.
E_STRICT will be part of
- Sqlite3 support via the ext/sqlite extension
- DirectoryIterator implements ArrayAccess
- Implementing Spl(Array|Index|Member)Reference
- Implement DualIterator
- Implement RecursiveTreeIterator