我有一个数组可以中断error_log(),但不能中断print_r(),并且在其他情况下也能很好地工作


I have an array that breaks error_log(), but not print_r(), and works perfectly otherwise

我要么遗漏了什么,要么在PHP 5.6.7中发现了一个错误。

我有一个数据数组,当我通过error_log()(编辑:使用print_r($array,true),所以我传递一个字符串)时,我得到;

Array
(
    [

我通常期望看到的地方;

Array
(
[person_id]=> 123456
)

就好像第一个数组键正在终止输出,但第一个数组密钥是一个空的子数组,没有什么奇怪的

奇怪的是,当我使用print_r()时,它可以很好地打印数组,并且所有基于数组的PHP函数(操作数组或对数组进行迭代)都不会对数组产生任何问题。

我的一些钥匙是这样的;

Array
(
[per_roles] => Array
    (
    )
[per_roles_retrieved] => 
[per_cache] => Array
    (
    )
[*member] => 
[*addresses] => 
[*marketing_preferences] => 
[*suppliers] => 
[_table] => address
[id] => 454545
[*exists] => 1
[*_related_objects] => Array
    (
    )
[*_related_object] => Array
    (
    )
[first_name] => John
[middle_name] => 
[last_name] => Smith
)

问题是什么?是星号吗?

根据http://php.net/manual/en/function.error-log.phperrorlog()函数将字符串作为参数,而不是数组。在调用error_log()之前,请尝试将数组转换为字符串。