json_decode 变量 PHP 上的 var_dump
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21405819/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
var_dump on a json_decode variable PHP
提问by luispcosta
quick question, im doing a var_dump on a json_decode variable in php like this:
快速问题,我在 php 中的 json_decode 变量上执行 var_dump ,如下所示:
var_dump(json_decode($some_Variable, true));
And, since $some_Variable is quite a long json string, it shows up like this in my browser:
而且,由于 $some_Variable 是一个很长的 json 字符串,它在我的浏览器中显示如下:
array (size=10)
0 =>
array (size=14)
'gameId' => int 1290161341
'invalid' => boolean false
'gameMode' => string 'CLASSIC' (length=7)
'gameType' => string 'MATCHED_GAME' (length=12)
'subType' => string 'RANKED_SOLO_5x5' (length=15)
'mapId' => int 1
'teamId' => int 200
'championId' => int 55
'spell1' => int 4
'spell2' => int 14
'level' => int 30
'createDate' => float 1390601626963
'fellowPlayers' =>
array (size=9)
...
'statistics' =>
array (size=44)
...
1 =>
array (size=14)
'gameId' => int 1291665162
'invalid' => boolean false
'gameMode' => string 'CLASSIC' (length=7)
'gameType' => string 'MATCHED_GAME' (length=12)
'subType' => string 'RANKED_SOLO_5x5' (length=15)
'mapId' => int 1
'teamId' => int 200
'championId' => int 236
'spell1' => int 4
'spell2' => int 21
'level' => int 30
'createDate' => float 1390674755052
'fellowPlayers' =>
array (size=9)
...
'statistics' =>
array (size=41)
...
(Yes its league of legends, im using Riot API (http://developer.riotgames.com/) to write a small application). As you can see, for instance the index 'fellowPlayers' doesnt show me the actual values in it, it just shows "..." and same for statistics, how can i do so it shows the all thing in every index?
(是的,它的英雄联盟,我使用 Riot API(http://developer.riotgames.com/)来编写一个小应用程序)。如您所见,例如索引“fellowPlayers”并没有向我显示其中的实际值,它只显示“...”,对于统计数据也是如此,我该怎么做才能显示每个索引中的所有内容?
回答by
Since json_decodereturns an array, try
由于json_decode返回一个数组,请尝试
$arJson = json_decode( $strJson, true );
var_dump( $arJson[ 0 ] );
Since you are printing each element, there is chance that the result may not be obfuscated.
由于您正在打印每个元素,因此结果可能不会被混淆。
回答by álvaro González
You're apparently using Xdebug, a PHP debugging extension that (among other features) overloads the native var_dump()functionwith its own fancy version. You can tweak its settings or simply disable it by setting the xdebug.overload_var_dumpdirective to false.
您显然在使用Xdebug,这是一个 PHP 调试扩展,它(除其他功能外)使用自己的花哨版本重载本机var_dump()函数。您可以调整其设置或通过将xdebug.overload_var_dump指令设置为false.
In php.ini:
在php.ini:
xdebug.overload_var_dump=0
In regular PHP code:
在常规 PHP 代码中:
<?php
ini_set('xdebug.overload_var_dump', 0);
回答by Joe Zim
Why don't you just dump the JSON? JSON is more readable and if you echoit, it won't be cut off. It won't be formatted nicely, but you can easily copy/paste it into an editor that will format it nicely (many IDE's can do this). Firefox's Scratchpad development tool can do it too.
为什么不直接转储 JSON?JSON 更具可读性,如果你愿意echo,它不会被切断。它不会被很好地格式化,但是您可以轻松地将它复制/粘贴到一个可以很好地格式化它的编辑器中(许多 IDE 可以做到这一点)。Firefox 的 Scratchpad 开发工具也可以做到。
回答by Rahma TV
Add this code at the end line of your php.ini, if you are using xampp C:\xampp\php\ php.ini
如果您使用的是 xampp C:\xampp\php\ php.ini,请将此代码添加到 php.ini 的末尾行
; with sane limits
xdebug.var_display_max_depth = 10
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024
; with no limits
; (maximum nesting is 1023)
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
Its work 100% for me
它对我来说是 100% 的工作

