Live data from Hacker News

PHP 5.4.0 released

php.net

21–30 of 103 posts

Re: PHP 5.4.0 released

#21
post #7

Other great little changes: - you can now do function()[0] - Seems like a return to sanity for the PHP team, at least temporarily.. I even kinda like the traits!

How is 'Also,

  Chained string offsets - e.g. $a[0][0] where $a is a string - now work.
I have no idea how is that supposed to work. What should be the outcome on, say:

  $a = "foo"; $a[0][0]
What about (assuming $a is still "foo"):

  $a[0][1]
etc.?

Re: PHP 5.4.0 released

#22
From here: http://www.php.net/manual/en/migration54.other.php

> Chained string offsets - e.g. $a[0][0] where $a is a string - now work.

Can someone explain why this is? I'm sure I'm misunderstanding, but this seems to mean that the following would work:

  $a = "Hello";
  echo $a[0]; //"h"
  echo $a[0][0]; // also "h"??
What's the point? To avoid failure if I pass a string instead of a 2-dimensional array?

Re: PHP 5.4.0 released

#23

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…

> 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

#25

From here: http://www.php.net/manual/en/migration54.other.php > Chained string offsets - e.g. $a[0][0] where $a is a string - now work. Can someone explain why this is? I'm sure I'm misunderstanding, but this seems to mean that the following would work: $a = "Hello"; echo $a[0]; //"h" echo $a[0][0]; // also "h"?? What's the point? To avoid failure if I pass a string instead of a 2-dimensional array?

Consistency. Since $a[0] is a string, you would expect $a[0][0] to work too.

Re: PHP 5.4.0 released

#26

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…

Some of those might just make me do some PHP again.

My thoughts exactly. If the situation warrants it.

Re: PHP 5.4.0 released

#27
post #21
post #7

Other great little changes: - you can now do function()[0] - Seems like a return to sanity for the PHP team, at least temporarily.. I even kinda like the traits!

How is ' Also, Chained string offsets - e.g. $a[0][0] where $a is a string - now work. I have no idea how is that supposed to work. What should be the outcome on, say: $a = "foo"; $a[0][0] What about (assuming $a is still "foo"): $a[0][1] etc.?

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 ?

Re: PHP 5.4.0 released

#28
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!!" With closures in 5.3, syntax improvements and removal of horrible features (register_globals, magic_quotes, etc) in 5.4, it's shaping up quite nicely.

Thanks, PHP devs!

Re: PHP 5.4.0 released

#29
post #21
post #7

Other great little changes: - you can now do function()[0] - Seems like a return to sanity for the PHP team, at least temporarily.. I even kinda like the traits!

How is ' Also, Chained string offsets - e.g. $a[0][0] where $a is a string - now work. I have no idea how is that supposed to work. What should be the outcome on, say: $a = "foo"; $a[0][0] What about (assuming $a is still "foo"): $a[0][1] etc.?

I'd say that "This allows short tags to be disabled for XML clash-avoidance while still allowing the user to use the short-form of echo.

Re: PHP 5.4.0 released

#30
post #21
post #7

Other great little changes: - you can now do function()[0] - Seems like a return to sanity for the PHP team, at least temporarily.. I even kinda like the traits!

How is ' Also, Chained string offsets - e.g. $a[0][0] where $a is a string - now work. I have no idea how is that supposed to work. What should be the outcome on, say: $a = "foo"; $a[0][0] What about (assuming $a is still "foo"): $a[0][1] etc.?

for '<?=', I see it as a good thing for using php for views. It's faster and more natural to read within typical display markups. Akin to the erb syntax.
Post reply on HN