Hello,
I got the:
array ( 0 => ' hello', 1 => 'hello', )
Yes I'm sure I'm using $_POST
Main Topics
Browse All TopicsHello,
I have a function in PHP:
myfunction($myvalue)
{
if ($myvalue == $_POST['entervalue'])
{
echo "yes";
}
else
{
echo "no";
}
}
suppose $myvalue = "hello" and $_POST['entervalue'] = "hello"
I have tried trim, ===, upload in binary/ascii format, and echo both value and they appeared to be the same, but I always get "no" instead of "yes"
If I do a strncmp(), it will return a negative value -104, -107!
Can someone please tell me how to fix the problem and compare two strings?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
hi,
http://in.php.net/strcmp
please go through this site
One thing to note in comparison with ==
When we make a comparison with == php automaticly converts strings to integers when either side of the comparison is an integer, f.e.:
<?
$value = 0;
if($value == "submit") {
echo "Let's submit";
}
?>
Above would be succesful, since "submit" is converted to an integer (eq 0) and the equation is would return true; (that's why (1 == "1submit") would also return true)
That's why we should use strcmp or === (checks type also), for string comparisons.
So my conclusion is that when comparing string, you'd better not make use of == (use strmp or === instead). For integer comparisons the == equation can be usefull, since our values will always be casted to an integer (1 == "1" returns true).
Regards,
M.Naveen Swamy
Business Accounts
Answer for Membership
by: RoonaanPosted on 2005-07-29 at 11:33:19ID: 14557502
what happens when you do
$_POST['entervalue']));
var_export(array($myvalue,
are you sure you should be using $_POST and not $_GET or $_REQUEST?
-r-