1

目前我使用包含系统创建了简单的网站

  1. header.php - 包含 HTML 页面的第一部分(标题、元标记、JS 代码...等)

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

    页面内容

我对阿拉伯语的主要问题

我必须把

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

在 page.php、footer.php<head>标签之间,否则阿拉伯语将无法正确支持。

由于这些标签,这会阻止页面验证。

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

谢谢

4

6 回答 6

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">';
于 2013-08-24T06:48:06.580 回答
2
  1. 使用这样的工具将阿拉伯字符串编码为 UTF-8 。(无需更改任何设置 - 该链接具有您需要的正确设置)。

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

例子:

<?php echo utf8_decode('your_encoded_string_goes_here'); ?>
于 2015-05-21T17:32:11.527 回答
1

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

于 2016-07-08T16:02:16.017 回答
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>

我的页面.php

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

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

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

脚.html

<div>my footer</div>

</body>
</html>
于 2013-08-18T20:49:06.047 回答
0

1-放这个

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

2-您还应该将文档保存为 UTF-8 而不是 ANSI

于 2015-01-22T15:07:39.117 回答
0
  1. 您的标题应如下所示:

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

于 2016-01-24T00:15:01.157 回答