Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51978 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73367 invoked from network); 22 Apr 2011 14:36:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Apr 2011 14:36:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 80.68.91.63 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 80.68.91.63 bytemark.phcomp.co.uk Received: from [80.68.91.63] ([80.68.91.63:59543] helo=bytemark.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/8A-58227-56291BD4 for ; Fri, 22 Apr 2011 10:36:24 -0400 Received: from freshmint.phcomp.co.uk ([78.32.209.33] helo=mint.phcomp.co.uk) by bytemark.phcomp.co.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.71) (envelope-from ) id 1QDHSy-0007vi-59; Fri, 22 Apr 2011 15:36:16 +0100 Received: from addw by mint.phcomp.co.uk with local (Exim 4.63) (envelope-from ) id 1QDHSx-0006L5-Jq; Fri, 22 Apr 2011 15:36:15 +0100 Date: Fri, 22 Apr 2011 15:36:15 +0100 To: Matt Pelmear Cc: internals@lists.php.net Message-ID: <20110422143615.GJ32571@phcomp.co.uk> Mail-Followup-To: Matt Pelmear , internals@lists.php.net References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] == Comparison type juggling From: addw@phcomp.co.uk (Alain Williams) On Fri, Apr 22, 2011 at 10:27:33AM -0400, Matt Pelmear wrote: > My questions are: > 1) What is the advantage to converting both strings to ints to compare them? It makes things easy for working on what comes back from a form (in $_POST/...). It is a nice feature, and works well *most* of the time. I do wish that the Perl way of doing it had been used, ie: == numeric compare eq text compare It solves many problems at the cost of a little more developer clue. I suppose that the proper way is to use as you say: if( (string) $a === (string) $b ) ..... or strcmp() -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include