EchoFool Posted April 7, 2009 Share Posted April 7, 2009 I am stuck with my php because my if statement is checking if the two values are the same "numerically" rather than if its string.. as the string consists of numbers its taking is number checking rather than string checking: <?php $X = 1; $Y = 0; $MyX = 00; $MyY = 10; $Check = '$X$Y'; $Check2 = '$MyXMyY'; If($Check == $Check2){ Echo 'ok'; } ?> So its basically saying: 10 is equal to 0010 Which is correct in numerical world but im trying use them as strings but it keeps just auto using it as numbers, how do tell it to check if they are the same strings ignoring their numerical value? Link to comment https://forums.phpfreaks.com/topic/153052-solved-if-statement-error/ Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 Try comparing them using '==='. Link to comment https://forums.phpfreaks.com/topic/153052-solved-if-statement-error/#findComment-803862 Share on other sites More sharing options...
premiso Posted April 7, 2009 Share Posted April 7, 2009 strcmp would be the easiest to compare 2 strings. Link to comment https://forums.phpfreaks.com/topic/153052-solved-if-statement-error/#findComment-803866 Share on other sites More sharing options...
EchoFool Posted April 7, 2009 Author Share Posted April 7, 2009 Thank you for the help! Link to comment https://forums.phpfreaks.com/topic/153052-solved-if-statement-error/#findComment-803899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.