我们在跑步PHP 5.3.10-1ubuntu3.15 with Suhosin-Patch
,我碰到了最奇怪的事情。我不断收到数组到字符串的转换错误。
这是一些带有行号的代码:
115 $report['report'][$key]['report'] = array();
116 watchdog('ranking_report_field', 'key is a: ' . gettype($key), array(), WATCHDOG_NOTICE);
117 $report['report'][$key]['report'] = array(
'#markup' => "<p>No information available.</p><p>For questions, <a href='mailto:$emailAddr'>email</a> your account executive ($emailAddr).</p>",
);
以下是这些行号的Drupal(顺序)日志:
Notice: Array to string conversion in foo() (line 115 of /var/www/...
key is a: string
Notice: Array to string conversion in foo() (line 117 of /var/www/...
据我所知,没有数组到字符串的转换应该发生。有人可以帮我一下吗-还是这只是碰到PHP的某种错误?
数组键之一映射到字符串而不是数组。这是一个有关如何发生此类错误的程序。
<?php
$key = 0;
$report = array();
$report['report'] = array();
$report['report'][$key] = 'report';
// Array to string conversion error
$report['report'][$key]['report'] = array();
// what I assume you are expecting is
$report['report'][$key] = array();
$report['report'][$key]['report'] = array(); // no more notices
注意:在他的时间OP还没有包含有关如何创建数组的信息
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句