相关疑难解决方法(0)

PHP json_encode json_decode UTF-8

如何将带有国际字符的json编码字符串保存到数据库,然后在浏览器中解析解码后的字符串?

<?php           
    $string = "très agréable";  
    // to the database 
    $j_encoded = json_encode(utf8_encode($string)); 
    // get from Database 
    $j_decoded = json_decode($j_encoded); 
?>    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <?= $j_decoded ?>
</html> 
Run Code Online (Sandbox Code Playgroud)

php json utf-8

24
推荐指数
6
解决办法
13万
查看次数

标签 统计

json ×1

php ×1

utf-8 ×1