On 29 July 2004 01:50, Jon Drukman wrote:
> with this code fragment:
>
> <?
>
> $string='/mobile/phone.html';
> if (strpos($string,'/mobile/')!==false) { print "one: yes\n"; }
> if (strpos($string,'/mobile/')===true) { print "two: yes\n"; }
>
> >
>
>
> only the first if statement prints anything. why is !==
> false not the
> same as === true ?
Because strpos returns the integer offset of the found substring, or FALSE
if not found; it *never* returns TRUE. (You need the !== test because
strpos() can return an offset of zero, which would be ==FALSE but not
===FALSE.)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php