我收到了这个警告
Warning: Illegal string offset 'class' in C:\xampp\htdocs\myweb\libraries\cms\html\html.php on line 971
Warning: Illegal string offset 'class' in C:\xampp\htdocs\myweb\libraries\cms\html\html.php on line 972
Warning: Illegal string offset 'class' in C:\xampp\htdocs\myweb\libraries\cms\html\html.php on line 972
在joomla 3.3(文件路径\ libraries \ cms \ html \ html.php)上,代码为:
public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
{
static $done;
if ($done === null)
{
$done = array();
}
$attribs['class'] = isset($attribs['class']) ? $attribs['class'] : 'input-medium';//happen here
$attribs['class'] = trim($attribs['class'] . ' hasTooltip');//happen here
$readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly';
$disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled';
if (is_array($attribs))
{
$attribs = JArrayHelper::toString($attribs);
}
.......
显示它与$ attribs ['class']有关。如果我是正确的非法字符串偏移可能意味着$ attribs不是一个数组而是一个字符串。有没有办法纠正这个?
我在使用PHP5.4
答案 0 :(得分:0)
此:
public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
{
}
应该是:
public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = array())
{
}
要点是默认情况下通过将“null”设置为变量,实际上它表示它是空字符串或空变量。通过设置“array()”,可以将变量定义为空数组。
通过进一步观察,预计会有一个数组,因为代码正在寻找特定的array_keys,例如:'readonly'AND'disable'。