>>>> 進入 ECSTART 論壇

字體:  

HTML url 傳遞中文參數給php

seanlee074 發表於: 2008-5-08 14:41 來源: EcStart |BLOG

ex
A1.html 傳param=台灣 到 B1.php時,
php去解析param會變成亂碼,
其他網站有說在apache 安裝 mod_encoding可以解決,
但 firefox解決了,可以ie還是一樣,
有好的建議嗎?

謝謝

最新回復

FIEND at 2008-5-08 16:28:28
echo "a1.html?param=".url_encode("台灣") ;
seanlee074 at 2008-5-08 16:51:03
echo "a1.html?param=".url_encode("台灣") ;<---這隻還是php,如果是隻html呢?
fillano at 2008-5-08 20:31:49
剛剛稍微試了一下,下面的例子在big5編碼下使用,似乎在ie7跟firefox都沒問題。如果是utf-8編碼,那就把mb_convert_encoding拿掉就可以。(檔名就叫test247.php)

CODE:

<html>
<body>
<div>
<?php
echo(mb_convert_encoding($_GET['val'],"BIG5","UTF-8"));
?>
</div>
<button onclick="gogo()">test</button>
<script>
function gogo() {
        window.location="test247.php?val="+encodeURI("我踏月色而來許功蓋");
}
</script>
</body>
</html>