json_encode()在某些情况下不会转义双逗号

时间:2015-06-11 10:49:58

标签: php json

以下是展示问题的小提琴:http://phpfiddle.org/lite/code/hd0t-ebjr

<?php
    require "simple_html_dom.php";

    $html = file_get_html("https://play.google.com/store/apps/details?id=com.vlambeer.RidiculousFishing&hl=en");

    $test = $html->find('.id-app-orig-desc', 0)->innertext;

    $data = [
        'test' => $test
    ];

    die(var_dump(json_encode($data)));
?>

向下滚动,您会注意到所有双引号都未正确转义。虽然其他字符是(&#34; /&#34;例如)。

奇怪的是,在将测试字符串复制到php代码中时,我似乎无法重现它。仅在从网址加载时。

知道这里会发生什么吗?

1 个答案:

答案 0 :(得分:1)

这些双引号实际上不是双引号。它们只是实体html,&quot;,无需逃避它。