Jump to content

Very strange if statement problem


dignick

Recommended Posts

I've just stumbled across a problem that is baffling me.

 

I've got two xml files.  Both have the same encoding.  I'm using simplexml to read them.

 

All I'm trying to do is an if statement to compare two values from the files.

 

if($flevel->smallname == $level) {
$fulllevel=$flevel->name;
break;
}

 

$level has been set previously from another xml file.  This if statement doesn't work.  If I echo the two values they equal the same thing.  If I test each against what they are set to, it returns true (ie $flevel->smallname=='admin' and $level=='admin').  if I hash the values in the statement it returns true (ie if(md5($flevel->smallname) == md5($level)) ).  I can't figure out why these variables are not equal! Here's some code I used to test, and the output.

 

if($flevel->smallname == 'admin') echo 'smallname<br />';
if($level == 'admin') echo 'level<br />';
$lvel = $flevel->smallname;
if($level == $lvel) echo 'lvel success!<br />';
if($level == $flevel->smallname) echo 'success!<br />';
if(md5($level) == md5($flevel->smallname)) echo 'md5 success!<br />';

 

Output:

smallname
level
md5 success!

 

 

Link to comment
https://forums.phpfreaks.com/topic/171528-very-strange-if-statement-problem/
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.