Jump to content

My Compare Function, It too simple, I don't see the error.


Recommended Posts

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.