Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21831 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62692 invoked by uid 1010); 9 Feb 2006 22:16:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62671 invoked from network); 9 Feb 2006 22:16:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2006 22:16:01 -0000 Received: from ([127.0.0.1:29888]) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with ECSTREAM id 0A/A0-35443-02FBBE34 for ; Thu, 09 Feb 2006 17:16:01 -0500 X-Host-Fingerprint: 24.24.2.57 ms-smtp-03.nyroc.rr.com NetCache Data OnTap 5.x Received: from ([24.24.2.57:54915] helo=ms-smtp-03.nyroc.rr.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id F4/20-35443-6DCBBE34 for ; Thu, 09 Feb 2006 17:06:14 -0500 Received: from [192.168.0.108] (rrcs-24-97-40-226.nys.biz.rr.com [24.97.40.226]) by ms-smtp-03.nyroc.rr.com (8.13.4/8.13.4) with ESMTP id k19M68sQ010437 for ; Thu, 9 Feb 2006 17:06:09 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v746.2) In-Reply-To: <200602092154.01908.pookey@pookey.co.uk> References: <200602092154.01908.pookey@pookey.co.uk> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: <01572697-D2DB-49A9-AF34-AF26BE79922F@yghe.net> Content-Transfer-Encoding: 7bit Date: Thu, 9 Feb 2006 17:06:08 -0500 To: internals@lists.php.net X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: Symantec AntiVirus Scan Engine Subject: Re: [PHP-DEV] 'odd' handling of $moo['bar'] where $moo is a string From: spam@yghe.net (Evan Priestley) When indexing a string, the string is cast to an integer: (int)'file' == 0 When in a conditional expression, the string is cast to a boolean: (bool)'file' == true It isn't necessarily a fatal error, consider: $keys[ '3' ] - Evan On Feb 9, 2006, at 4:54 PM, Ian P. Christian wrote: > Can someone explain the following to me? > > echo "DEBUG:\n"; > var_dump($keys); > var_dump($keys['file']); > var_dump(isset($keys['NOTEXISTING'])); > var_dump(isset($keys['file'])); > exit; > > > DEBUG: > string(19) "myConsoleController" > string(1) "m" > bool(true) > bool(true) > > > Now, it seems that $keys['file'] == $keys[0], which makes sense why > the issets > return true. However... > if ('file') echo 'true'; > will print moo, therefore 'file' == 1, not 0. Why is this different > when using > it as a string offset? > IMO, using a string as a string offset, a fatal error should be > raised. > > Kind Regards, > > -- > Ian P. Christian > http://pookey.co.uk > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php