What is new in PHP 5.3 – part 4: __callStatic, OpenID support, user.ini, XSLT profiling and more
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.
__callStatic()
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 | <?php Foo::bar(); class Foo { 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 | <?php $class = 'bar'; $class::method(); $class::$member; $class::CONST; $namespace = 'foo'; $namespace::$class::method(); ?> |
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 +;user_ini.filename = + +; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) +;user_ini.cache_ttl = 300 |
OpenID support
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.
XSLT profiling
Christian Stocker mentioned in his blog that he added his XSLT profiling to the official PHP source.
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.
Error levels
E_STRICT will be splitted to E_STRICT and E_DEPRECATED. 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 E_ALL.
Other improvements
- Sqlite3 support via the ext/sqlite extension
array_replace[_recursive]functions-
SPL improvements:
- DirectoryIterator implements ArrayAccess
- Implementing Spl(Array|Index|Member)Reference
- Implement DualIterator
- Implement RecursiveTreeIterator
Posted in
content rss

November 20th, 2007 at 9:48 am
i think you should sleep a bit sometimes
Anyway, great articles. I cant wait for more.
November 20th, 2007 at 12:34 pm
In this list, Improved ini handling and OpenID support seem the most interesting to me – hopefully with this inclusion we should see OpenID become more popular on the web.
November 20th, 2007 at 5:34 pm
I don’t mind the __callStatic naming, but I wish they’d stick to some standard with those. For instance, __call becomes ambiguous when you add _callStatic and so appending another word onto __call would be advisable in order to make clear what it does and doesn’t do.
November 20th, 2007 at 5:44 pm
[...] Hodicska has posted part four of his “what’s new in PHP 5.3″ series – a sort of “wrapup” for some [...]
November 20th, 2007 at 6:47 pm
I would really like to see nowdocs implemented in 5.3. It would definitely make a lot of code more readable instead of having to escape things or use concatenation in long strings.
November 24th, 2007 at 8:04 pm
[...] What is new in PHP 5.3 – part 4 (0 visite) [...]
November 26th, 2007 at 6:19 pm
[...] What’s coming in PHP 5.3 Listen [...]
November 29th, 2007 at 10:06 pm
Looks fine
December 1st, 2007 at 1:23 am
I think the name convention of using __callStatic(); is just plain ugly, and those that be should have left it as it was, and let PHP it’s self determine if the call to the class method was static or dynamic.
I can only pray that those that be don’t go ahead (as you suggest?), and make the changes to the other magic methods. In fact, can we have __callStatic(); removed (now)?
February 9th, 2008 at 8:12 pm
are there any docs available for these ini-directives?
April 1st, 2008 at 11:03 pm
What I cannot understand about PHP versions is, that most basic things are missing, yet they implement OpenID. It is to me as if the dev’s would implement any fancy feature which comes their way but pay little attention to the small details.
Anyway, language elements are a welcome addition and I’m really happy about .htaccess FastCGI options. Sometimes, it’s a real pain in the neck to configure something without them.
April 3rd, 2008 at 10:55 pm
I dont known if the problem is with my build version, but,
$methodparameter of__callStaticreturns method name in lower case, its very wrong.It happened with function
get_classin previous versions, later it was fixed. i hope it will be fixed.May 11th, 2008 at 5:56 pm
[...] w wersji 5.4 idzie w bardzo dobrym kierunku. Zapowiada się implementacja magicznej metody __callStatic() analogicznej do __call(). Problem będzie w instalacji najnowszej wersji na polskich serwerach. W [...]
July 15th, 2008 at 2:48 pm
[...] En attendant, une petite news: PHP5.3 intégrera la méthode magique __callstatic. [...]
August 8th, 2008 at 8:39 pm
it looks like a nice site, thanks..
September 23rd, 2008 at 3:40 pm
__construct()
__destruct()
__call()
__callStatic()
__get()
__set()
__isset()
__unset()
__sleep()
__wakeup()
__toString()
__set_state()
__clone()
serialize()
unserialize()
can you give explanation of these magic method when the method is called and what is the use of every method? I am learning PHP.
thank you
July 7th, 2009 at 1:39 pm
[...] dynamic static calls – Klassi meetodi dünaamiline väljakutsumine. Kui enne pidi dünaamiliseks väljakutsumiseks kasutama kohmakaid call_user_func/call_user_func_array funktsioone, siis alates 5.3-st piisab järgmisest: $cls = “Klass123″; $meth = “doSomething”; $result = $cls::$meth ($param1); [...]