如何使用ChromePhp Logger记录数组
Hi all I have the ChromePhp logging extension set up with PhpConsole and it's working fine.
大家好我已经使用PhpConsole设置了ChromePhp日志记录扩展,它运行正常。
But the usual ChromePhp::log("Variable value: ".$variable)
doesn't like having $variable as an array. It throws an array to string conversion error.
但通常的ChromePhp :: log(“变量值:”。$ variable)不喜欢将$ variable作为数组。它会将数组抛出到字符串转换错误。
Is there an in-built method to log the array in human readable format, just like javascript's console.log(array)
. Or is it a case of iterating over the array and passing each index and value.
是否有一种内置方法以人类可读的格式记录数组,就像javascript的console.log(数组)一样。或者是迭代数组并传递每个索引和值的情况。
1 个解决方案
#1
2
Ah easy sorry I got it. I just need to split it into two logs.
很抱歉,我明白了。我只需要将它分成两个日志。
ChromePhp::log("Array contents: ");
ChromePhp::log($array);
This prints to the console as expected in human readable format.
这将按照人类可读的格式打印到控制台。
You cant concatenate an array onto a string in the logger.
您无法将数组连接到记录器中的字符串。
更多相关文章
- PHP用空格分割文本为数组的方法
- 几个有用的php字符串过滤,转换函数代码
- 在数组中计数,其中值为0
- 如何将PHP数组的关联数组转移到javascript?
- PHP - 将字符串转换为键值数组
- 使用mod_rewrite将文件夹转换为查询字符串
- 计算字符串的MD5哈希值
- 如何在不更改其键值的情况下删除数组的第一个元素?
- 有一种防弹的方法可以检测php字符串中的base64编码吗?