7 ms·
Big hitters: array dereferencing - $object->method()[$index] is now valid syntax built-in webserver via CLI - php -s - http://php.net/manual/en/features.comma
by randomdrake 15y ago
Big hitters:
array dereferencing - $object->method()[$index] is now valid syntax
built-in webserver via CLI - php -s - http://php.net/manual/en/features.commandline.webserver.php http://php.net/manual/en/features.commandline.webserver.php
traits and the insteadof operator - http://php.net/language.oop5.traits.php http://php.net/language.oop5.traits.php
shortened array syntax - $array = [1, 2, [1, 2, 3], 4];
Finally removed register_globals ;)
Default charset of UTF-8!
Read all about it! http://www.php.net/manual/en/migration54.php http://www.php.net/manual/en/migration54.php
- duskwuff 15y ago> Finally removed register_globals ;) They've also removed magic_quotes. A few functions that queried its status still exist, but you can't turn it on.
- smsm42 15y agoAlso it is faster and much better on memory consumption (depends on app of course, but 10-20% speedup and 20-30% less peak memory have been observed on some mainstream apps).
- blakeperdue 15y agoAre these numbers based on most previous versions of PHP? I'm on 5.3.10, do you think if I upgraded I would see similar improvements?
- tomcorrigan 15y agoIn a word: Yes. Of course, depending on your app YMMV!
- smsm42 15y agoYes, most probably you will see significant improvements. Of course, it depends on your app - if your app spends 99% of time in SQL database calls, PHP can do nothing about it. But PHP part would be faster and take less memory.
- manuletroll 15y agoSome of those might just make me do some PHP again.
- regularfry 15y agoMy thoughts exactly. If the situation warrants it.
- tabbyjabby 15y agoReally looking forward to traits. We have some hacks using interfaces and __call that we have been using to try and approximate traits, but the real thing is always much better. :)
- maratd 15y agoSame here. This is a move away from inheritance to mixins. They did a stellar job with it and it's really flexible. Check out http://us2.php.net/traits http://us2.php.net/traits for the nitty-gritty.
- roel_v 15y agoI've used traits a few times and in each case replaced it later by either inheritance or moving the functionality into separate classes. I'm not getting the design considerations that call for traits over alternatives. How would one use, and why is it the better option?
- nolok 15y agoAmongst other things, traits are a way to provide interface delegation. Imperfect, but a lot better than the current solutions.
- nikic 15y agoThe www.php.net mirror will only be rsynced tomorrow, for now use http://docs.php.net/manual/en/migration54.php http://docs.php.net/manual/en/migration54.php instead to get infos about 5.4 features. It's a good bit more up to date.
- shaunxcode 15y agoI am curious what the internal hang up is which prevents: funcReturnsFunc(1)(2)
- masklinn 15y ago> I am curious what the internal hang up is which prevents: PHP's parser is... not exactly a great work of software engineering.
- smsm42 15y agoMain problem there is $foo→bar()() which seems to be harder to implement on top of existing parser. Otherwise the patch is here: https://wiki.php.net/rfc/fcallfcall https://wiki.php.net/rfc/fcallfcall but since it's not complete it wasn't merged.
- lukifer 15y agoThat array syntax is beautiful, been waiting for that for a long time.
- evincarofautumn 15y agoThis bug was apparently “not a bug”: https://bugs.php.net/bug.php?id=51672 https://bugs.php.net/bug.php?id=51672
- rll 15y agoWell, it wasn't a bug. That was more of a feature request which is now implemented.
- evincarofautumn 15y agoIt’s been a feature request for at least eight years, it should never have arisen in the first place, and it should have been a one-line fix even if it had arisen. I don’t mean to knock PHP too badly; it’s quite useful, even if it is rather quirky. I just find it so unfortunate that this silly thing got so out of hand.
- smsm42 15y agoIt's not "one liner", and couldn't be if you understand how PHP engine works. But it wasn't super-hard to implement, just nobody got to it till now. It did not "get out of hand" by any measure. Once there was a consensus that this feature is needed by the significant part of PHP community, it was implemented. Could it be done earlier? Maybe, so could a lot of other nice things.
- pkulak 15y agoI just did a Google search for register_globals... mind boggling.
- rickmb 15y agoPHP was originally designed for simple, procedural bits of logic inside individual HTML pages. In that context, there's nothing wrong with the feature itself.
- rickmb 15y agoPHP was originally designed for simple, procedural bits of logic inside individual HTML pages. In that context, there's nothing wrong with the feature itself.
- mhitza 15y agoYou forgot (new Object)->method()