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 !==
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 ?
-jsd-
--
PHP General
On Wed, 28 Jul 2004 17:50:01 -0700, Jon Drukman [EMAIL PROTECTED] 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
Because === and !== check the type as well. Of you set $string =
'blah' you'll still get the same result.
If you were using != and == both would print.
strpos() returns an int, so comparing it to false with === is always
false. The same would be true for true.
That's half right. strpos actually
Heck, even I got it wrong ;) True check below should always fail...
Jason Barnett wrote:
Because === and !== check the type as well. Of you set $string =
'blah' you'll still get the same result.
If you were using != and == both would print.
strpos() returns an int, so comparing it to false with
5 matches
Mail list logo