我有一个简单的$_GET[]查询变量集,用于在从数据库中提取查询时显示测试数据.
I have a simple $_GET[] query var set for showing testing data when pulling down queries from the DB.
<?php if($_GET['test']): ?> <div id="test" style="padding: 24px; background: #fff; text-align: center;"> <table> <tr style="font-weight: bold;"><td>MLS</td></tr> <tr><td><?php echo KEY; ?></td></tr> <tr style="font-weight: bold;"><td>QUERY</td></tr> <tr><td><?php echo $data_q; ?></td></tr> <tr style="font-weight: bold;"><td>DATA</td></tr> <tr><td><?php var_dump($data); ?></td></tr> </table> </div> <?php endif; ?>当我做var_dump时,正如预期的那样,这是大数组字符串,它们都被弄脏了.是否有至少为此添加换行符或以更易读的方式显示var_dump的方法?公开后,我愿意接受有关处理字符串的jQuery建议.
When I do var_dump, as expected it's this big array string that is all smushed together. Is there a way to add in line breaks at least for this or display the var_dump in a way that's more readable? I'm open to jQuery suggestions on manipulating the string after it's posted.
推荐答案我真的很喜欢var_export().如果您喜欢可复制/粘贴的代码,请尝试:
I really love var_export(). If you like copy/paste-able code, try:
echo '<pre>' . var_export($data, true) . '</pre>';甚至是这样的颜色语法高亮显示:
Or even something like this for color syntax highlighting:
highlight_string("<?php\n\$data =\n" . var_export($data, true) . ";\n?>");您可以使用print_r()执行相同的操作.对于var_dump(),您只需添加<pre>标记:
You can do the same with print_r(). For var_dump() you would just need to add the <pre> tags:
echo '<pre>'; var_dump($data); echo '</pre>';更多推荐
使var
发布评论