Live data from Hacker News

PHP 5.4.0 released

php.net

51–60 of 103 posts

Re: PHP 5.4.0 released

#51
post #12

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…

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).

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

#52
post #12

Earlier quoted context omitted.

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).

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?

In a word: Yes. Of course, depending on your app YMMV!

Re: PHP 5.4.0 released

#53
post #27

Earlier quoted context omitted.

I always thought it was weird and kind of stupid, but I'm genuinely curious how is that great thing. How is it weird and stupid? is better than ?

Good tools complain about <?= because it does not start with a named target. A lot of people just haven't read about the idea behind processing instruction syntax, which is also why we keep seeing mistakes like <%.

A PHP script isn't an XML document, so processing instructions aren't really relevant. Even if your script is outputting XML, the script itself isn't going to be read by an XML parser.

Re: PHP 5.4.0 released

#54
post #43

This is a nice list of improvements. As someone who spends a lot of the day in PHP-land, this is going to make me happy. As someone who also controls our entire server stack, waiting for someone else to decide to upgrade will not be a problem :) I'm glad the PHP devs are starting to actually make it a "real" language. It seems like PHP has always been the fat kid bumbling along behind everyone shouting "wait up guys!…

> waiting for someone else to decide to upgrade will not be a problem :) It is sad that a lot of servers are not like this, and PHP 5.4 will take ages to appear, if at all. Heck, I know of a hosting company still using PHP4.

Funny, I just had to deploy an existing site to a PHP4-only hosting environment. After a few hours of re-writing things I've been taking for granted (a lot of timezone code namely) everything worked fine. But yuck, I felt dirty afterwards.

Re: PHP 5.4.0 released

#55
post #46
post #41

Earlier quoted context omitted.

The best part of short array syntax is that now you don't need named parameters to be supported by the language. function foo($opts) { echo $opts['source'] . $opts['destination']; } // just one extra pair of [] needed instead of new array() foo(['source' => '/123', 'destination' => '/abc']);

While I agree that it makes it easier to hack in that functionality, it would still be very useful to have named parameters for functions that don't implement that functionality. For example, fgetcsv takes parameters for delimiter, enclosure, and escape char (as of 5.3). Right now, if I want to specify a different enclosure, I'm forced to specify a delimiter even if I still want to use the default. I'd much prefer th…

> While I agree that it makes it easier to hack in that functionality, it would still be very useful to have named parameters for functions that don't implement that functionality.

Absolutely. But PHP devs have repeatedly refused to support named parameters so this is a good enough fix.

Re: PHP 5.4.0 released

#56
post #41
post #5

I'm glad to see the short array syntax. Having strayed from PHP for a while to work on Ruby and JavaScript I'm really enjoying the ability to leave out semicolons in unambiguous end-of-line situations. Would love to see that make it into PHP at some point.

The best part of short array syntax is that now you don't need named parameters to be supported by the language. function foo($opts) { echo $opts['source'] . $opts['destination']; } // just one extra pair of [] needed instead of new array() foo(['source' => '/123', 'destination' => '/abc']);

Unfortuately, this method of passing an array as a single parameter, rather than actual parameters, is not very self-documenting and leads to more difficult to understand code.

Re: PHP 5.4.0 released

#59

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…

That array syntax is beautiful, been waiting for that for a long time.

Re: PHP 5.4.0 released

#60
These features can only be good for PHP. Now the community needs to step up and care for the language better. We have seen the popularity of many languages and frameworks rise and fall, but php keeps chugging along. Modern frameworks are awesome, but the community is still rather fractured. I would love to see people more proud of php, to get over the fads around them. Now the language is getting some nice features, I think it's our time to shine :)
Post reply on HN