0

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?

Thanks

hakre
  • 193,403
  • 52
  • 435
  • 836
EOB
  • 2,975
  • 17
  • 43
  • 70
  • 2
    did you check the string encoding? – ajreal May 23 '12 at 08:40
  • No, what exactly do you mean? How can I check the encoding? – EOB May 23 '12 at 08:41
  • 1
    `ä` is different in windows-1252 (http://en.wikipedia.org/wiki/Windows-1252) utf-8 (http://en.wikipedia.org/wiki/Utf-8). This function might helpful to detect the string encoding http://php.net/manual/en/function.mb-detect-encoding.php – ajreal May 23 '12 at 08:43
  • It says UTF-8 ... what do I do with that information now? – EOB May 23 '12 at 08: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 `` (http://stackoverflow.com/questions/4696499/which-one-to-use-meta-charset-utf-8-vs-meta-http-equiv-content-type) – ajreal May 23 '12 at 08:49
  • What's happen when you do var_dump($post['maintopics'] == '-1--- Bitte wählen Sie ein Thema aus --' && $post['subtopics'] == 'Bitte wählen Sie erst eine Oberkategorie...'); ? – Alexandre May 23 '12 at 11:41

1 Answers1

0

Try to define this in the beginning of your file:

ini_set( 'default_charset', 'UTF-8' );
mb_internal_encoding('UTF-8');

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.

Marcio Mazzucato
  • 8,841
  • 9
  • 64
  • 79