当我编码json时会出现奇怪的字符


strange characters when I encode json

我有以下代码,它在php中编码json

$arr = array('htmlOutput' => $htmloput, 'no_rows' => 'blah');
    echo json_encode($arr);

$htmloput包含html标记。

由于某些原因,输出中有很多''r''n''t''t''t''t''t''t''t。另外,当您在JSON中编码时,标记中的单引号或双引号是否会导致任何proples?

这些字符是空白字符的文本表示。'r为回车。'n是换行符。而't就是标签。报价应该无关紧要。

其他一些(来自字符串文档):

  • "''t"(ASCII 9(0x09)),一个选项卡
  • "''n"(ASCII 10(0x0A)),新行(换行)
  • "''r"(ASCII 13(0x0D)),回车
  • "''0"(ASCII 0(0x00)),NUL字节
  • "''x0B"(ASCII 11(0x0B)),一个垂直选项卡