I see a lot of mentions of zend in extension names, function names.. Could someone elaborate how Zend relates to PHP?
PHP 5.4.0 released
31–40 of 103 posts
Re: PHP 5.4.0 released
#32Big 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…
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
#33Other 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.?
It makes sense when you think of it in offsets. $string[offset] means that given $a = 'foo' then $a[0] is f and given $a = 'f' then $a[0] is f. Thus $a[0][0] would be the first offset of the first offset of "foo". $a[0][1] would not be valid, of course.
Also it's not really something you should ever use, but it's definitely more consistent than throwing an error.
Re: PHP 5.4.0 released
#34Earlier quoted context omitted.
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
#35Now the question is, when will this become available in mainstream Linux distributions? I guess Arch et al. will get it pretty quickly, followed by Ubuntu 12.10 or maybe 13.04 depending on how many packages it affects. Good ol' Debian, on the other hand, might or might not get it in time for the Wheezy freeze. CentOS? Forgetaboutit.
Re: PHP 5.4.0 released
#36Other 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.?
> $a = "foo"; $a[0][0]
$a is a string "foo" $a[0] is a string "f" equating to substr($a, 0, 1) $a[0][0] is a string "f" equating to substr($a[0], 0, 1)
> $a[0][1]
This will give an undefined index error, same thing as $a[42] for exemple, since index 1 doesn't exists in $a[0] (= "f")
Re: PHP 5.4.0 released
#37Re: PHP 5.4.0 released
#38Now the question is, when will this become available in mainstream Linux distributions? I guess Arch et al. will get it pretty quickly, followed by Ubuntu 12.10 or maybe 13.04 depending on how many packages it affects. Good ol' Debian, on the other hand, might or might not get it in time for the Wheezy freeze. CentOS? Forgetaboutit.
Re: PHP 5.4.0 released
#39From 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.
php > $a = "Hello";
php > echo $a[0];
H
php > echo $a[0][0];
PHP Fatal error: Cannot use string offset as an array in php shell code on line 1Re: PHP 5.4.0 released
#40Earlier quoted context omitted.
Consistency. Since $a[0] is a string, you would expect $a[0][0] to work too.
Thanks. Let me rework my original question then. Why the hell didn't it always work? php > $a = "Hello"; php > echo $a[0]; H php > echo $a[0][0]; PHP Fatal error: Cannot use string offset as an array in php shell code on line 1