Possible Duplicate:
The 3 different equals
Can anyone tell me why, when using the code below, I am getting redirected to elephant.com rather than seeing a ‘giraffe!
<?php
$foo="giraffe";
if($foo="elephant"){
header("location:http://www.elephant.com");
exit();
}else{
echo $foo;}
?>
Thanks for looking
J
You’re assigning
$foohere, rather than comparing it; you should be doing:The result of an assignment operation is the value that’s just been assigned; in this case, ‘elephant’ is evaluating to true.