Lamez Posted May 12, 2010 Share Posted May 12, 2010 I'm more or less getting a logic error, so I cannot provide any syntactical errors. The function in question is suppose to take two variables and compare them. I also have a boolean variable to see if I care about the case of the variables. However if I do something like this: compare("NAME", "name", false); The function returns false. Here is the function: function compare($var1, $var2, $caseMatters){ if(!$caseMatters && !is_numeric($var1) && !is_numeric($var2)){ strtolower($var1); strtolower($var2); } return md5($var1) === md5($var2); } Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/201528-my-compare-function-it-too-simple-i-dont-see-the-error/ Share on other sites More sharing options...
kenrbnsn Posted May 12, 2010 Share Posted May 12, 2010 These two lines <?php strtolower($var1); strtolower($var2); ?> don't assign their results to anything. You need to do: <?php $var1 = strtolower($var1); $var2 = strtolower($var2); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/201528-my-compare-function-it-too-simple-i-dont-see-the-error/#findComment-1057286 Share on other sites More sharing options...
Lamez Posted May 12, 2010 Author Share Posted May 12, 2010 Gosh, how come I did not see that. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/201528-my-compare-function-it-too-simple-i-dont-see-the-error/#findComment-1057290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.