Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86519 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87634 invoked from network); 9 Jun 2015 12:40:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2015 12:40:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.172 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:33578] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/63-00828-9BED6755 for ; Tue, 09 Jun 2015 08:40:25 -0400 Received: by wiwd19 with SMTP id d19so16803824wiw.0 for ; Tue, 09 Jun 2015 05:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Ee1kBVOWUDc532nv19MVBqnZb6mdsu0gHDCsiDgHnww=; b=Fzt0ZSRpwozp0+MEewCyLB6jR8lkQ3avBtsbOT4lGpSuFiwUsWINuGQgrond9stywX rCZUAoDU1EyViq0q+T3mo09KxdJMrzJbo9+1UmbBDHUBpN6eujO4jL+e5e3BaEwseUsR t/G0qvh9oWfgcCOkL8gtOf3g5pwE9WvwbaBITprPiozkYwTEDjChK9JaiTMou00IS44/ qVGVk8fK96TKek6p1w4tRQ5YXYopHAk+B1yLr8izI1E1NGhPAM5w5nwRHuDI7q4EuGo0 C+NBxSLDLzLgwxYBfD9FxlYipZnVWT2/flVZNLAEmZh6YLp3TQOyTPjq1OyjsJpDGefg R/ew== X-Received: by 10.180.77.102 with SMTP id r6mr7995765wiw.87.1433853623175; Tue, 09 Jun 2015 05:40:23 -0700 (PDT) Received: from [192.168.0.159] ([62.189.198.114]) by mx.google.com with ESMTPSA id k2sm2665346wif.3.2015.06.09.05.40.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2015 05:40:22 -0700 (PDT) Message-ID: <5576DE54.4010407@gmail.com> Date: Tue, 09 Jun 2015 13:38:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: internals@lists.php.net References: <5576051A.3040800@gmx.de> In-Reply-To: <5576051A.3040800@gmx.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Array dereferencing of scalars From: rowan.collins@gmail.com (Rowan Collins) Christoph Becker wrote on 08/06/2015 22:11: > The behavior of dereferencing scalars as if they were arrays or strings > is arguable: > > $foo = 42; > $foo['bar']; // => NULL A few things to note here: - accessing a *numeric* offset of a *string* is valid (selects a single character) - accessing a *string* offset of another string is interpreted as access to character 0, with a Warning issued - de-referencing this to two levels ($string['key']['key']) and then attempting to write is a Fatal error - as discussed elsewhere, coercing a NULL to an array seems perfectly reasonable - assigning to an offset of anything other than a string or array results in a Warning and no change to the variable While I agree that it's kind of surprising not to get even a Notice in your example, I'm not 100% sure what the behaviour should be, given how many different scenarios already have different behaviour. Maybe someone needs to come up with a generalised rule? Regards, -- Rowan Collins [IMSoP]