PHP print() Arabic string

后端 未结 5 1679
无人共我
无人共我 2021-01-20 05:32

When I try and execute this code to print out an Arabic string: print(\"إضافة\"); I get this output: إضاÙØ©. If I utf8_decode() it I\'ll get <

5条回答
  •  天涯浪人
    2021-01-20 05:43

    It might be necessary to indicate to the browser which charset you are using -- I'm guessing it's UTF-8.

    IN order to achive that, you might try putting this portion of code at the beginning of your script, before any output is generated :

    header('Content-type: text/html; charset=UTF-8');
    


    [utf8_decode][1] will try to decode your string from UTF-8 to latin1, which is not suited for Arabic characters -- hence the '?' characters.

提交回复
热议问题