Re: Re: string comparison

From: Date: Fri, 23 Aug 2002 13:26:56 +0000
Subject: Re: Re: string comparison
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-113764@lists.php.net to get a copy of this message
"Support @ Fourthrealm.Com" <support@fourthrealm.com> wrote in message news:5.1.0.14.2.20020823092847.0d34d980@mail.bighost.ca... > $section would always be a string in this case, but that is good to know > for future development. > > What is the === comparison? > > > > At 06:19 AM 8/23/2002 -0700, you wrote: > >Actually, the two are very different. If $section was set to 0 for > >example, then: > > > > if($section == 'logout') > > > >would return true whereas > > > > if(strcmp($section, 'logout')) > > > >would return false. strcmp() forces a string type comparison. > > > > if($section === 'logout') > > > >would be comparable. > > > >-Rasmus > > > >On Fri, 23 Aug 2002, Kondwani Spike Mkandawire wrote: > > > > > > > > "Support @ Fourthrealm.Com" <support@fourthrealm.com> wrote in > > > message > > > > > > news:5.1.0.14.2.20020823091004.09ebe940@mail.bighost.ca... > > > > > > > > Would both of these generate the same result? > > > > > > > > Is there an advantage of one over the other? > > > > > > > > 1) if (strcmp($section, 'logout')) > > > > > > > > 2) if ($section == 'logout')) > > > > > > > > > > > > Peter > > > > > > > > > > > > > > They do achieve the same goal... I'd say > > > the later would be more advantageous coz > > > you are simply using a logic statement hence > > > in terms of the time factor it should be quicker... > > > Where as in the first one we are making > > > a call to a function hence there ought to be > > > a couple of steps that are executed algorithmically... > > > > > > Spike > > > > > > > - - - - - - - - - - - - - - - - - - - - - > > > > Fourth Realm Solutions > > > > pbechard@fourthrealm.com > > > > http://www.fourthrealm.com > > > > Tel: 519-739-1652 > > > > - - - - - - - - - - - - - - - - - - - - - > > > > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > - - - - - - - - - - - - - - - - - - - - - > Fourth Realm Solutions > pbechard@fourthrealm.com > http://www.fourthrealm.com > Tel: 519-739-1652 > - - - - - - - - - - - - - - - - - - - - - *My baad* I overlooked the returning of 0 if equal of the strcmp method... I was only thinking in terms of true and false... i.e anything >0 == true anything less than 0 == false I overlooked the mid part...

« previous php.general (#113764) next »