WEB/PHP
[PHP] JQuery load() 사용으로 넘긴 변수의 한글깨짐 현상
Ezcode
2011. 4. 12. 17:01
A.php 에서 JQuery의 load()를 사용하여 B.php로 변수를 넘겼다.
아래의 함수를 사용하여 해결
$(document).ready(function() {
$("#position").load("b.php",{
"a01":"한글한글",
"b01":"ABCABC"
});
});
B.php에서 넘어온 변수의 한글이 깨지는 현상 발생 ~_~아래의 함수를 사용하여 해결
function unescape($text) {
return urldecode(preg_replace_callback('/%u([[:alnum:]]{4})/', create_function(
'$word',
'return iconv("UTF-16LE", "UHC", chr(hexdec(substr($word[1], 2, 2))).chr(hexdec(substr($word[1], 0, 2))));'
), $text));
}