>From the docs :
Note: It is easy to mistake the return values for "character found at position 0" and 
"character not found".  Here's how to detect
the difference:

// in PHP 4.0b3 and newer:
$pos = strpos($mystring, "b");
if ($pos === false) { // note: three equal signs
    // not found...
}

// in versions older than 4.0b3:
$pos = strpos($mystring, "b");
if (!is_integer($pos)) {
    // not found...
}

Andrey

----- Original Message -----
From: "Rick Emery" <[EMAIL PROTECTED]>
To: "'Andrey Hristov'" <[EMAIL PROTECTED]>; "Rick Emery" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, March 22, 2002 3:58 PM
Subject: RE: [PHP] comparisons


> Andrey, you are incorrect.
>
> From the manual on strpos():
> int strpos (string haystack, string needle [, int offset])
> If needle is not found, returns FALSE.
>
> -----Original Message-----
> From: Andrey Hristov [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 22, 2002 7:47 AM
> To: Rick Emery
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] comparisons
>
>
>
> > if (ereg("john",$jeff) ) { }
> >
> ok
> > or:
> >
> > if( strstr( $jeff, "john") ) { }
> >
> ok
> > or:
> >
> > if( strpos( $jeff, "john") ) { }
> error
>
> if  (strpos($jeff, "john") !== FALSE)
>
> Best regards,
> Andrey Hristov
>
>
> --
> 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

Reply via email to