我正试图通过网址传递阿拉伯文,然后将其作为会话工作以英文填写。
说我有接下来的
www.example.com?subject=الاختبار
然后转到jquery ajax帖子,然后它回到浏览器,如下所示????
الاختبار
var params = {
sessionid: "<?php if(isset($_GET['sessionid'])){echo $_GET['sessionid'];}else{ echo ""; } ?>",
subject: <?php if(isset($_GET['subject'])){echo "'".$_GET['subject']."'";}else{ echo ''; } ?>,
};
$.post("ajax_login.php", params,function(data){
if(data=='yes') //if correct login detail
{
document.location='secure.php';
}
else
{
alert("Woops their seems to be a problem please check back later.");
}
}
然后ajax_login.php是
<?php session_start();
echo "yes";
//now set the session from here if needed
$user = array();
$user['sessionid'] = $_POST['sessionid'];
$user['subject'] = $_POST['subject'];
$_SESSION['user'] = $user;
if($_SESSION['user']){
//print_r($_SESSION);
}else{
echo "there is an error";
exit();
}
然后我只是在secure.php中执行print_r($ _ SESSION ['user'])
答案 0 :(得分:0)
首先:确保在抓取$_GET['subject']
第二:在您最喜欢的文本编辑器中。 Notepad++
确保编码
Encode UTF-8 without BOM
还尝试确保页面字符集是utf-8
答案 1 :(得分:0)
也许是PHP没有正确解释URL - 尝试设置/确保PHP中的默认字符集是UTF-8,以便正确处理阿拉伯字符。
在php.ini文件中更改/添加
default_charset = "utf-8"