Also 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).
Re:PHP 5.4.0 released
by blakeperdue on Thursday March 01, 2012 @09:27PM
(#3655084)
Are 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?
Yes, 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.
Re:PHP 5.4.0 released
by tomcorrigan on Thursday March 01, 2012 @09:56PM
(#3655136)
In a word: Yes.
Of course, depending on your app YMMV!
> 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.
That array syntax is beautiful, been waiting for that for a long time.
Re:PHP 5.4.0 released
by evincarofautumn on Friday March 02, 2012 @11:11AM
(#3657071)
This bug was apparently “not a bug”: https://bugs.php.net/bug.php?id=51672
Well, it wasn't a bug. That was more of a feature request which is now implemented.
Re:PHP 5.4.0 released
by evincarofautumn on Friday March 02, 2012 @11:24AM
(#3657128)
It’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.
It'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.
You forgot (new Object)->method()
The www.php.net mirror will only be rsynced tomorrow, for now use 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.
Re:PHP 5.4.0 released
by shaunxcode on Thursday March 01, 2012 @09:25PM
(#3655082)
I am curious what the internal hang up is which prevents:
funcReturnsFunc(1)(2)
> I am curious what the internal hang up is which prevents:
PHP's parser is... not exactly a great work of software engineering.
> PHP is... not exactly a great work of software engineering.
FTFY. :)
You can do better? As smart man as you are surely can figure out where to send the patches.
Main 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 but since it's not complete it wasn't merged.
Re:PHP 5.4.0 released
by tabbyjabby on Thursday March 01, 2012 @05:27PM
(#3654387)
Really 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. :)
Same 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 for the nitty-gritty.
I'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?
Amongst other things, traits are a way to provide interface delegation. Imperfect, but a lot better than the current solutions.
Re:PHP 5.4.0 released
by manuletroll on Thursday March 01, 2012 @05:21PM
(#3654362)
Some of those might just make me do some PHP again.
Re:PHP 5.4.0 released
by regularfry on Thursday March 01, 2012 @05:42PM
(#3654460)
My thoughts exactly. If the situation warrants it.
I just did a Google search for register_globals... mind boggling.
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
traits and the insteadof operator - 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