FAQ
Hi Nikita,
On Thu, Nov 21, 2013 at 12:26 AM, Nikita Popov wrote:

The current behavior is that anything "falsey" (e.g. null, false and the
empty string) is silently cast to array when an array operation is applied
to it. I don't like that behavior, but it's somewhat internally consistent
now. Changing it for strings *only* seems a bit weird.

Persuasive argument.
I prefer to change the behavior if I have to choose, though.

$a = ''; // empty string
$a[10] = 'a';
echo $a; // "Array"

would be common pit hole when users are trying to use string as array of
chars.
I don't know why, but there are 436 FB likes! for this PR even if there is
no "likes!"
button on the page. There may be a lot of users that are unhappy with this
behavior.

Document and warn users?
Or should we change behavior even if it seems odd?

I don't mind at all setting up RFC to vote.
Any comments?

--
Yasuo Ohgaki
yohgaki@ohgaki.net

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 10 | next ›
Discussion Overview
groupphp-internals @
categoriesphp
postedNov 19, '13 at 11:48p
activeNov 22, '13 at 1:44a
posts10
users4
websitephp.net

People

Translate

site design / logo © 2022 Grokbase