我收到这样的请求,网址如下:http://domain.com/page.php?text= {阿拉伯语Word}
现在我正在尝试使用$ _GET ['text']获取文本,但我一直认为它是“????????” ,问题是什么
<?php
header('Content-type: text/html; charset=UTF-8');
include('EnTransliteration.class.php');
$tr = new EnTransliteration();
$str = iconv( "utf-8//TRANSLIT//IGNORE","windows-1256", $_GET['text']);
$en_str = $tr->ar2en($str);
$string = <<<XML
<root>
<translation>$en_str</translation>
</root>
XML;
$xml = new SimpleXMLElement($string);
header('Content-type: text/xml; charset=UTF-8');
echo $xml->asXML();
?>
答案 0 :(得分:0)
您的Apache服务器可能不接受UTF-8 URL编码。请参阅this答案以解决您的问题。
希望它会有所帮助:)
答案 1 :(得分:0)
您的HTML表单需要明确声明数据必须以UTF-8格式发送。否则,它将使用用户的语言环境,这可能不代表windows-1256,当然也不代表UTF-8。
e.g。
<form action="" method="get" accept-charset="UTF-8">
答案 2 :(得分:0)
也许这可以提供帮助:
<?php
$title = 'أبجد هوز';
$path1 = '/product/'.rawurlencode($title);
echo $path1."<br>";
$path2 = rawurldecode($path1);
echo $path2;
?>
答案 3 :(得分:-1)
1开启
2开启记事本
3 - 编写代码
4 - 保存文件时make Encoding:utf-8
5个文件名name.html name.php