0

My if ($man == "â") or else If ($man == "¤") doesnt work. Cant php read those symbols?

My question is, how can i check If $man = â or ¤

If i echo 'man = : ' . $man; It shows â or ¤

echo"<td>";

If ($man == "â"){
print("<img class='sol' src='sad.png'>");
}
else If ($man == "X"){
print("<img class='sol' src='x.png'>");
}
else If ($man == "¤"){
print("<img class='sol' src='sunny.png'>");
}
else 
print("<p class='bigtxt'>$man</p>");

echo "</td>\n";
Moe
  • 84
  • 6
  • Possible duplicate of [How to display special characters in PHP](http://stackoverflow.com/questions/12699037/how-to-display-special-characters-in-php) – roberrrt-s Nov 28 '16 at 14:32
  • 1
    what's the output of `var_dump(urlencode($man), urlencode('â'), urlencode('¤'))`? – Federkun Nov 28 '16 at 14:35
  • PHP has *no* problems with things like the currency symbol (as long as you're utf-8 all the way through)... but please, please read a PHP coding style guide - this looks like VB with added curly braces and it makes me sad :( – CD001 Nov 28 '16 at 14:38
  • Output is : string(3) "%E2" string(6) "%C3%A2" string(6) "%C2%A4" – Moe Nov 28 '16 at 14:45
  • 1
    Your file is (correctly) utf-8-encoded, but your `$man` isn't. The byte `E2` represent the `â` character in the ISO-8859-1 encoding. Where/how did you retrive `$man`? Which encoding do you want use? – Federkun Nov 28 '16 at 14:48
  • I solved it like this. Thanks to @federkun . $urman = urlencode($man); and then If ($urman == "%E2") – Moe Nov 28 '16 at 14:50
  • Make a answer so i can give u thumbs up – Moe Nov 28 '16 at 14:52
  • No, you don't solve anything with that. You just need to be consistent with the encoding, that's how you solve the problem – Federkun Nov 28 '16 at 14:52
  • There's a reason I wrote *UTF-8 all the way through* : http://stackoverflow.com/questions/279170/utf-8-all-the-way-through/279279 < pretty much the defacto canonical answer for all encoding issues on SO. – CD001 Nov 28 '16 at 14:56

0 Answers0