All pastes #185994 Raw Edit

Jemt

public text v1 · immutable
#185994 ·published 2006-09-29 13:40 UTC
rendered paste body
The example below will output "Word NOT found", even though the word was actually found.

$str = "This is a test";
$pos = strpos($str, "This");

if ($pos)
	echo "Word found";
else
	echo "Word NOT found";


====================================================================================================

This example outputs the proper results, thanks to type checking (Word found)

$str = "This is a test";
$pos = strpos($str, "This");

if ($pos === false)
	echo "Word NOT found";
else
	echo "Word found";