News for hackers. Stuff that matters.
Re:PHP 5.4.0 released by randomdrake on Thursday March 01, 2012 @05:00PM (#3654263)
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

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

Re:PHP 5.4.0 released by smsm42 on Thursday March 01, 2012 @05:20PM (#3654355)
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?
Re:PHP 5.4.0 released by smsm42 on Friday March 02, 2012 @12:02PM (#3657308)
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!
Re:PHP 5.4.0 released by duskwuff on Thursday March 01, 2012 @05:37PM (#3654437)
> 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.

Re:PHP 5.4.0 released by lukifer on Friday March 02, 2012 @01:06AM (#3655571)
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
Re:PHP 5.4.0 released by rll on Friday March 02, 2012 @11:16AM (#3657088)
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.
Re:PHP 5.4.0 released by smsm42 on Monday March 05, 2012 @04:26AM (#3665986)
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.

Re:PHP 5.4.0 released by mhitza on Friday March 02, 2012 @03:32AM (#3655878)
You forgot (new Object)->method()
Re:PHP 5.4.0 released by nikic on Thursday March 01, 2012 @07:47PM (#3654867)
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)

Re:PHP 5.4.0 released by masklinn on Friday March 02, 2012 @03:07AM (#3655830)
> I am curious what the internal hang up is which prevents:

PHP's parser is... not exactly a great work of software engineering.

Re:PHP 5.4.0 released by bazerka on Friday March 02, 2012 @07:36AM (#3656361)
> PHP is... not exactly a great work of software engineering.

FTFY. :)

Re:PHP 5.4.0 released by smsm42 on Monday March 05, 2012 @04:15AM (#3665965)
You can do better? As smart man as you are surely can figure out where to send the patches.
Re:PHP 5.4.0 released by smsm42 on Monday March 05, 2012 @04:19AM (#3665977)
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. :)
Re:PHP 5.4.0 released by maratd on Thursday March 01, 2012 @06:02PM (#3654528)
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.
Re:PHP 5.4.0 released by roel_v on Friday March 02, 2012 @03:18AM (#3655851)
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?
Re:PHP 5.4.0 released by nolok on Friday March 02, 2012 @05:35AM (#3656131)
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.
Re:PHP 5.4.0 released by pkulak on Friday March 02, 2012 @01:48AM (#3655653)
I just did a Google search for register_globals... mind boggling.
Re:PHP 5.4.0 released by rickmb on Friday March 02, 2012 @02:10AM (#3655709)
PHP was originally designed for simple, procedural bits of logic inside individual HTML pages. In that context, there's nothing wrong with the feature itself.