Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36096 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17513 invoked from network); 11 Mar 2008 10:44:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2008 10:44:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=scott.mcnaught@synergy8.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=scott.mcnaught@synergy8.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain synergy8.com designates 202.174.102.11 as permitted sender) X-PHP-List-Original-Sender: scott.mcnaught@synergy8.com X-Host-Fingerprint: 202.174.102.11 au01.synergy8.com Linux 2.6 Received: from [202.174.102.11] ([202.174.102.11:33388] helo=au01.synergy8.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/85-21537-7A266D74 for ; Tue, 11 Mar 2008 05:44:56 -0500 Received: from 124-171-171-76.dyn.iinet.net.au ([124.171.171.76] helo=scott) by au01.synergy8.com with esmtpa (Exim 4.68) (envelope-from ) id 1JZ1yQ-0002YT-M1; Tue, 11 Mar 2008 20:44:46 +1000 To: "'Pierre Joye'" Cc: References: <20080311094214.GA4264@redhat.com> <-1466067017711567869@unknownmsgid> In-Reply-To: Date: Tue, 11 Mar 2008 20:44:50 +1000 Message-ID: <001301c88364$ef314150$cd93c3f0$@mcnaught@synergy8.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AciDYjuZMqbfJVAiRV+D/aUQFrEemgAASQPg Content-Language: en-us X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - au01.synergy8.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - synergy8.com Subject: RE: [PHP-DEV] Comparison: ('*' == 0) ... True or false From: scott.mcnaught@synergy8.com ("Scott McNaught [Synergy 8]") "If you compare an integer with a string, the string is converted to a number. If you compare two numerical strings, they are compared as integers." Well... I just feel stupid now :) I am writing something which is extracting parts of a crontab. The variable contained "*" was being compared to 0. This would have clicked for me had it been anything else, but because it was "*" my thoughts were that there was some new wild-card thing going on that I hadn't heard about. Cheers guys and sorry for my dumb post! Scott -----Original Message----- From: Pierre Joye [mailto:pierre.php@gmail.com] Sent: Tuesday, March 11, 2008 8:25 PM To: Scott McNaught [Synergy 8] Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Comparison: ('*' == 0) ... True or false On Tue, Mar 11, 2008 at 11:17 AM, Scott McNaught [Synergy 8] wrote: > Hey guys, > > I don't know whether to post this as a bug or not. But I was tricked when programming today. > > It seems that the character "*" is non-strictly equivalent to 0. Is this the correct behavior or am I missing something? > > Test case: > > > var_dump('*' == 0); > > ?> > > Shows boolean(true). > > I was unable to find any documentation as to why this would be the case. http://www.php.net/manual/en/language.operators.comparison.php -- Pierre http://blog.thepimp.net | http://www.libgd.org -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php