Re: == Comparison type juggling

From: Date: Fri, 22 Apr 2011 14:36:15 +0000
Subject: Re: == Comparison type juggling
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-51978@lists.php.net to get a copy of this message
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 <std_disclaimer.h>

« previous php.internals (#51978) next »