Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87910 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48034 invoked from network); 25 Aug 2015 13:35:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Aug 2015 13:35:49 -0000 Authentication-Results: pb1.pair.com header.from=nicolai.scheer@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nicolai.scheer@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.174 as permitted sender) X-PHP-List-Original-Sender: nicolai.scheer@gmail.com X-Host-Fingerprint: 209.85.160.174 mail-yk0-f174.google.com Received: from [209.85.160.174] ([209.85.160.174:33247] helo=mail-yk0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/44-05482-53F6CD55 for ; Tue, 25 Aug 2015 09:35:49 -0400 Received: by ykll84 with SMTP id l84so155276904ykl.0 for ; Tue, 25 Aug 2015 06:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=O09WoC18i80I6iiW5HmFBWZ7nLoVoHe6LDKqHovhC3Q=; b=gTOIhV2vIjIMqRxAngAocGaZIMuo+cbmuvD2L+Crv+Rvzubrl5U0PPNvgROEqKpvAs F5NfeDU4PhzptcZhL31VTFO9Uf7RqKzhiNyD2iCqlh34fZG2R2hSakcu+udJS3mbF6Az dkLun7nMcIgmgLGwk+Z5+UHJqG83VetXx+VvVmxIO5mRkYLM3a7QPXGG8Y3ZPiOQEysq qSBywtGU202XXjZM8RPOoE5H2Ri4V0yipoO/mX4/p+bA38v6aK6h34zSjSRDH0GqPlhJ zANv9lS+pDiH7jGc4l/QhYUlBuzXF7OIZiddrvWmuqxotPtc40nFa5XdIWpsiEGJf2A/ cnpQ== MIME-Version: 1.0 X-Received: by 10.170.198.88 with SMTP id p85mr33831781yke.94.1440509746877; Tue, 25 Aug 2015 06:35:46 -0700 (PDT) Received: by 10.37.115.21 with HTTP; Tue, 25 Aug 2015 06:35:46 -0700 (PDT) Date: Tue, 25 Aug 2015 15:35:46 +0200 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Notice on non existing array key (on a boolean) From: nicolai.scheer@gmail.com (Nicolai Scheer) Hi all, I'd expect the following code to throw a notice/warning: $x = true; $y = $x['foo']; It executes completely silently. $y is NULL afterwards, which is expected, since the right hand side of the assignment is undefined. If $x was an array (e.g. empty array), a E_NOTICE would be emitted. Can anyone shed a light on this behaviour? If accessing non existing array keys is worth a notice, shouldn't accessing an array index on a non array be worth a notice as well (maybe even a warning)? The other way round emits a warning (i.e. writing to an array key on a non array): $x = true; $x['foo'] = 'bar'; Warning: Cannot use a scalar value as an array ... Thanks for any insight, greetings Nico