PHP print () Arabic string

When I try to execute this code to print the Arabic line: print("إضافة"); I get this conclusion: Ø¥Ø¶Ø§ÙØ© . If I utf8_decode (), will I get ????? . I have "AddLanguage ar" in my apache configuration, but that does not help. How to print this arabic line?

+3
source share
5 answers

Also set the page language to utf8, for example:

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

and then see if it works. If this still does not work, go and check this, this is the complete solution for the Arabic language using PHP:

http://www.ar-php.org/en_index_php_arabic.html

You can also check this:

http://www.phpclasses.org/browse/package/2875.html

+9
source

You may need to tell the browser which encoding you are using - I assume UTF-8.

To achieve this, you can try putting this piece 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 suitable for Arabic characters - hence the characters '?' .

+8
source

You might want to install

 default_charset = "utf-8" 

in php.ini . The default charset directive tells the server to create the correct content type header.

You can also do this at runtime:

 ini_set('default_charset', 'utf-8'); 
+1
source

You can also check your browser font if it supports Arabic. Stick to regular fonts like Arial Unicode and Times New Roman.

0
source

Well,

First: Add HTML Top

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 

second: if you use AJAX encoding data using encodeURIComponent

Third: The first line of your PHP page should be

 header('Content-Type: text/html; charset=utf-8'); 

and decode data sent to PHP using urldecode

Hi,

0
source

All Articles