Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91114 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57297 invoked from network); 8 Feb 2016 15:10:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2016 15:10:02 -0000 Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:50683] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/82-36326-9CFA8B65 for ; Mon, 08 Feb 2016 10:10:02 -0500 Received: from [127.0.0.1] (unknown [82.240.16.115]) (Authenticated sender: flaupretre@free.fr) by smtp2-g21.free.fr (Postfix) with ESMTPSA id 3C5114B01C0; Mon, 8 Feb 2016 16:07:26 +0100 (CET) To: Stanislav Malyshev , Nikita Popov References: <56A3A01F.1020500@php.net> <56AE8735.4070901@gmail.com> <56AFC8CC.6040201@gmail.com> <56B6680F.6070804@gmail.com> Cc: Internals Message-ID: <56B8AFC1.7040100@php.net> Date: Mon, 8 Feb 2016 16:09:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56B6680F.6070804@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 160208-2, 08/02/2016), Outbound message X-Antivirus-Status: Clean Subject: Re: [PHP-DEV] [RFC] Generalize support of negative string offsets From: francois@php.net (=?UTF-8?Q?Fran=c3=a7ois_Laupretre?=) Hi, Slightly off-topic but, as I was looking for the way to add support for '$str[]=' assignments, I found something strange. Just for curiosity, does someone know a reason for this : $str = "abc"; $str[1]="z"; var_dump($str); // -> string(3) "zbc" -> Expected $str = ""; // Empty string $str[1]="z"; var_dump($str); // -> array(1) { [0]=>string(1) "z" } -> !!! The input string is converted to an array if it is empty. This becomes still funnier with : $str="a"; $str[] = 'z'; // -> Fatal error : [] operator not supported for strings $str=""; $str[] = 'z'; // -> OK -> $str gets array(1) { [0]=>string(1) "z" } Thoughts ? Regards François