Re: Re: string comparison
| From: | Joseph W. Goff | Date: | Fri, 23 Aug 2002 14:21:53 +0000 |
| Subject: | Re: Re: string comparison | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-113772@lists.php.net to get a copy of this message | ||
a triple = comparison is type sensitive.
i.e.
if ("0" == 0) // true
if ("0" === 0) // false, comparing string vs. int
----- Original Message -----
From: "Support @ Fourthrealm.com" <support@fourthrealm.com>
To: <php-general@lists.php.net>
Sent: Friday, August 23, 2002 8:29 AM
Subject: Re: [PHP] Re: string comparison
> $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
> - - - - - - - - - - - - - - - - - - - - -
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>