Jump to content

[SOLVED] strpos output confusing


Gleasonator

Recommended Posts

Hi all.

 

$string = strpos("Hello, world.", "universe");
echo $string;

 

Comes up with a blank page.

 

Yet, when I do this I don't get the desired result.

 

$string = strpos("Hello, world.", "universe");
if ($string = false)
{
$message = 'Not found in string.';
}
else
{
$message = 'Found in string at ' . $string . ' character(s) in.';
}

echo $message;

 

According to W3C Schools, the output should be false if the string cannot be found? http://www.w3schools.com/php/php_string.asp

 

I can't seem to get it to return as false. If I change if ($string = false) to if ($string = '') it still outputs as true... because the message that's echoed is:

 

Found in string at character(s) in.

 

Anyone think they can help?

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/114385-solved-strpos-output-confusing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.