php - 数组中的数据不一样
问题描述
我有一个我创建的数组。当用它读取数组时print_r
,没有返回输入正确的数据!我缺少特定的部分,例如< & >
带有标题的括号。
我怎样才能保存这些?
代码:
$params = array(
"Parm1" => "test",
"Parm2" => "hi",
"Parm3" => GUID(),
"Parm4" => "lol",
"Parm5" => "
<R>
<R1>the</R1>
<R2>dog</R2>
<R3>is</R3>
<R15>happy</R15>
<R20>today</R20>
</R>
");
基本上,唯一混乱的数据是该Parm5
部分。我希望里面的所有东西都能原样返回!EG:按原样阅读我只收到Array ( [Parm1] => test [Parm2] => hi [Parm3] => B18BE727-8F79-4D4A-80EA-3974B1429F78 [Parm4] => lol [Parm5] => the dog is happy today )
来自print_r
我想返回:
Array ( [Parm1] => test [Parm2] => hi [Parm3] => B18BE727-8F79-4D4A-80EA-3974B1429F78 [Parm4] => lol [Parm5] => <R><R1>the</R1> <R2>dog</R2> <R3>is</R3> <R15>happy</R15> <R20>today</R20></R> )
解决方案
htmlspecialchars
在 的返回值上使用print_r
:
echo "<pre>";
echo htmlspecialchars(print_r($params, true));
echo "</pre>";
推荐阅读
- python - 如何使用 Google Books API 返回包含多本书的搜索结果?
- vue.js - 如何修复未显示子路由的 Vue 3 路由?
- python - Python 中 Tkinter 的 Mac OS 的 wm_overridedirect 方法的替代方案
- kubernetes - 如何使用 initContainer 设置环境变量或修改主容器的启动命令?
- json - 加载到雪花变体列中的 JSON 文件大小
- php - PHP中的同步进程
- reactjs - 如何将无头 cms 与 React 集成
- full-text-search - Sphinx 搜索引擎在示例代码中创建错误
- command-line - 使用命令行从 Box 下载文件夹
- python - Pytest Mock socket.socket.connect 函数