2013-08-18 41 views
0

编码阿拉伯语目前我创建了简单的网站使用包括系统使用UTF8

  1. 的header.php - 包含HTML页面的第一部分(头部,meta标签,JS代码...等)

  2. page.php文件 - 包含简单的PHP代码

    页面内容

我妈在阿拉伯语

问题,我必须把

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
在page.php文件

,footer.php <head>标签之间,否则阿拉伯语将不能正确支持。

由于这些标记,这可以防止页面验证。

有什么方法可以避免这个问题吗?

感谢

+0

什么验证? – 2013-08-18 20:40:00

回答

0

所有你需要的是把这个

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

在您在您的网页/ include_once

编辑文件。例如:

了header.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
    <head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <title>my title in العربية</title> 
    </head> 
    <body> 

mypage.php

<?php 
include_once 'header.html'; 
?> 

<p> 
العربية 
</p> 

<?php 
include 'foot.html'; 
?> 

foot.html

<div>my footer</div> 

</body> 
</html> 
+0

该怎么办?你能举个例子吗? – DrOsama

+0

@ user2215342这应该工作 – raj112

+0

不工作:(为什么? – DrOsama

3
// Send a raw HTTP header 
    header ('Content-Type: text/html; charset=UTF-8'); 

    // Declare encoding META tag, it causes browser to load the UTF-8 charset 
    // before displaying the page. 
    echo '<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />'; 

    // Right to Left issue 
    echo '<body dir="rtl">'; 
0

1把这个

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

2 - 你也应该保存文档UTF-8不是ANSI

3
  1. 编码字符串阿拉伯成UTF-8使用工具like this。 (无需更改任何设置 - 该链接具有您需要的正确设置)。

  2. 然后使用utf8_decode()解码字符串。

例子:

<?php echo utf8_decode('your_encoded_string_goes_here'); ?> 
0
  1. 你的标题应该显示如下:

    <!DOCTYPE html> 
    <html lang="ar"> 
    <head> 
        <meta charset="utf-8"> 
    </head> 
    <body> 
    
  2. 将文档保存为UTF-8

1

除了所有的答案...确保您的(HTML/PHP)文件保存与正确的编码utf-8