displaying Arabic text using PHP

basrah_university68

New Member
Messages
9
Reaction score
0
Points
1
Hi,

I am trying to use Arabic text using PHP. for some reasone I get ????? ????? displayed.

Displyaing text using HRML files works fine.

I save the file as utf-8.

For example, the test file below only displays ????

"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">";

<HTML lang="AR-IQ" dir=rtl charset=UTF-8>
<HEAD>";
<meta http-equiv="Content-Language" content="ar-kw">
<TITLE>My Website</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
echo "</HEAD>";
echo "<BODY>";
echo "<span lang='ar-kw'يبمشبمشنتيبنتئيةىوةرىئءؤرنسنن سنيبمنستي </span>";

echo "<p> ننتا وءةؤىروءؤ رمنسيب </p>";


echo "</BODY>";
echo " </HTML>";
?>
 

wazam199419

New Member
Messages
11
Reaction score
0
Points
0
You could use something like this?

PHP:
<?php

echo <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>TITLE HERE</title>
</head>
<body>
<p>Put what ever here.</p>
</body>
</html>
EOF;
?>

Also try changing the language via CPanel.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. Don't use the short tags <? ?>. Use the full tags <?php ?>

2. Remove the quotes and semicolon from the first line and others that are outside the php tags
"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">";

3. Close the span tag <span lang='ar-kw'

4. Make sure save the file with utf-8 encoding. You might be saving it with another coding.

5. http://badges.x10.bz/arabic.php shows that it can work.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
There's nothing wrong using short tags. It doesn't effect the file at all.

While it isn't a problem in this case, their use is deprecated and some setups they are turned off. Using the full tags is just a good habit to get into.
 

basrah_university68

New Member
Messages
9
Reaction score
0
Points
1
Thanks you all for your answers.

I updated the code to:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML lang="AR-IQ" dir=rtl charset=UTF-8>
<HEAD>
<meta http-equiv="Content-Language" content="ar-kw">
<TITLE>My Website</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY>
<?php

echo "<p> ننتا وءةؤىروءؤ رمنسيب </p>";

?>
</BODY>
</HTML>

THis is saved as utf-8.

still the browser display ??????

when I remove the PHP section and pust instead of that <p> ننتا وءةؤىروءؤ رمنسيب </p> then save the file as HTML. then it displays the text correctly.

I do dnot have this kind of problem on other free webhosting. The only think I did not like there was they add alot of adds to my page.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Did you click on the link I posted?

That page is hosted on x10hosting. So it is not the server or the hostings fault.

Again, go to cPanel-->File Manager.
Create a new file.
Open it in the regular Editor.
Change the encoding to utf-8 and click on 'open'
Code the page
Save
View.
 

basrah_university68

New Member
Messages
9
Reaction score
0
Points
1
Thanks Descalzo,

I followed your instructions. I deleted the file on the server.

This time I used cPanel to create a new file, then copy and pasted the contnt from the file I had on my PC to the file in File Manager. Save it as utf-8. It worked.

I don't understand why this needs to be done using cPanel. Usually I create the file on my PC, then use a FTP program to uopload the file.

Now I know how to do this work on this site.

Thanks
 
Top