Re: [RFC] Generalize support of negative string offsets
| From: | Yasuo Ohgaki | Date: | Wed, 10 Feb 2016 07:00:06 +0000 |
| Subject: | Re: [RFC] Generalize support of negative string offsets | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91180@lists.php.net to get a copy of this message | ||
On Wed, Feb 10, 2016 at 3:51 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> Behavior regarding array. (a bit off topic, but error level should
> match with new string '{}' errors.)
>
> php > error_reporting(-1);
> php > $v=array();
> php > $v .= 'abc';
>
> Notice: Array to string conversion in php shell code on line 1
> php > var_dump($v);
> string(8) "Arrayabc"
>
> This insane string assignment raises E_NOTICE. PHP may be better to
> raise E_WARNING for this kind of invalid assignments just like
Additional comment on this
php > $v=array(1,2,3);
php > $v .= 'abc';
Notice: Array to string conversion in php shell code on line 1
php > var_dump($v);
string(8) "Arrayabc"
I think $v .= 'abc' should not destroy array variable. It's minor issue, though.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net