php - 如何在 PHP 中使用 var_dump() 查看长字符串的全部内容

标签 php arrays var-dump

我有一个包含一些字符串的数组,比如

$array = array("string1","string2","string3");

但是那些字符串很长,有时有 2000+ 的长度。所以当我这样做的时候

echo "<pre>";
var_dump($array);
echo "</pre>";

它向我展示了类似的东西

string 'zzzzzzzzzzzzzzzzz '... (length = 994)
string 'yyyyyyyyyyyyyyyyy '... (length = 1287)
string 'xxxxxxxxxxxxxxxxx '... (length = 1718)

而不是完整的字符串。我怎样才能看到数组的全部内容?对于那些会问的人,它包含 HTML 标签,所以这就是为什么我不写 echo $array[string];

最佳答案

您正在使用 xdebug,它会重载默认的 var_dump() 以提供更漂亮和更可配置的输出。默认情况下,它还会限制一次显示多少信息。要获得更多输出,您应该更改一些设置。

将此添加到脚本的顶部:

ini_set("xdebug.var_display_max_children", '-1');
ini_set("xdebug.var_display_max_data", '-1');
ini_set("xdebug.var_display_max_depth", '-1');

来自 the docs :

xdebug.var_display_max_children

Type: integer, Default value: 128

Controls the amount of array children and object's properties are shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces.

To disable any limitation, use -1 as value.

This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature.

xdebug.var_display_max_data

Type: integer, Default value: 512

Controls the maximum string length that is shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces.

To disable any limitation, use -1 as value.

This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature.

xdebug.var_display_max_depth

Type: integer, Default value: 3

Controls how many nested levels of array elements and object properties are when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces.

The maximum value you can select is 1023. You can also use -1 as value to select this maximum number.

This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature.

关于php - 如何在 PHP 中使用 var_dump() 查看长字符串的全部内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34342777/

相关文章:

php - Amazon Webservice 上的 mySQL RDS 实例性能

php - 无法从 JSON 文件获取正确的值到 MySQL 服务器

Javascript 检查数组中的现有对象

php - PHP中var_dump输出后的方括号

PHP问卷计算设计

php - 快速可靠地更新聊天室的最佳方法?

c - 如何将二维数组的每个元素递增 2

arrays - 如何在函数中将 swift 数组作为 UnsafePointer<T> 参数传递

php - 为什么在数字前加0会改变它的值

php - 限制嵌套对象深度的 var_dump 实现