Take the 2-minute tour ×

I have this code:

if($post['maintopics'] == '-1--- Bitte wählen Sie ein Thema aus --' && $post['subtopics'] == 'Bitte wählen Sie erst eine Oberkategorie...') {
                echo 'test';

On my local Windows it prints "test", the same code on a Linux server does not print "test". I tried logging the values before the if is executed and they are exactly the same as in the if. Any idea why this is not working on my server?


share|improve this question
did you check the string encoding? –  ajreal May 23 '12 at 8:40
No, what exactly do you mean? How can I check the encoding? –  EOB May 23 '12 at 8:41
ä is different in windows-1252 (en.wikipedia.org/wiki/Windows-1252) utf-8 (en.wikipedia.org/wiki/Utf-8). This function might helpful to detect the string encoding php.net/manual/en/function.mb-detect-encoding.php –  ajreal May 23 '12 at 8:43
It says UTF-8 ... what do I do with that information now? –  EOB May 23 '12 at 8:46
Is the $post value from a form submission? If so, you need to check is your web page use encoding UTF-8, which is like <meta charset="UTF-8" /> (stackoverflow.com/questions/4696499/…) –  ajreal May 23 '12 at 8:49
show 1 more comment

1 Answer

Try to define this in the beginning of your file:


Additionally, check if you are saving your PHP file in UTF-8 format without BOM, Notepad++ is a nice option to see this.

I had some headaches if enconding too, hope it can help you.

share|improve this answer
add comment

Your Answer


