如何在PHP中解码URL?

时间:2013-05-17 18:31:30

标签: php actionscript utf-8 url-encoding

我正在尝试从ActionScript向PHP发送请求,除了utf-8字符外,它还能正常工作。我的动作做了类似的事情:

var request:URLRequest = new URLRequest(url); 

并且PHP端接收URL并对其进行处理(即将数据插入MySQL),如下所示:

    $text = @$_GET['text'];
    $text = urldecode($text);
    $pdo->query("INSERT INTO mytable(thetext) VALUES ('$text')");

现在,当ActionScript中的变量URL为:

http://localhost/my_test_script.php?action=insert&text=non_utf_characters

我在MySQL表中看到正确插入了值"non_utf_characters"

但当网址是这样的时候:

http://localhost/my_test_script.php?action=insert&text=utf_characters_like_%C5%9E%C3%87%C3%96

它应该能够插入"utf_characters_like_ŞÇÖ"

但它只会插入"utf_characters_like_"

那么我应该怎样做才能让php从URL识别这些字符?

我尝试了什么:

  1. 正如您在php代码中看到的,我尝试过urldecode()
  2. 我尝试过header('Content-Type: text/plain; charset=utf-8');
  3. 我已将所有文件保存为UTF-8而没有BOM

0 个答案:

没有答案