我只需要这些PHP专家的帮助。我对PHP有一点了解。我收到了此代码的PHP Fatal error: Unsupported operand types
:
$ticket_item_types += array(
val_paperworkticket => 19,
val_disposal => 9,
comment => 22,
loadtime => 20,
bbls => 23,
disposalticketno => 46,
load_reviewed => 31
);
答案 0 :(得分:1)
如果键是变量,则必须在变量名之前使用$
,因此它必须是:
$ticket_item_types += array(
$val_paperworkticket => 19,
$val_disposal => 9,
$comment => 22,
$loadtime => 20,
$bbls => 23,
$disposalticketno => 46,
$load_reviewed => 31
);
如果它们是字符串,则必须引用它们:
$ticket_item_types += array(
'val_paperworkticket' => 19,
'val_disposal' => 9,
'comment' => 22,
'loadtime' => 20,
'bbls' => 23,
'disposalticketno' => 46,
'load_reviewed' => 31
);
另外,请考虑带有数组的+
运算符不能理解为sum运算符,而是Union
运算符
+运算符返回附加到左侧数组的右侧数组;对于存在于两个数组中的键,将使用左侧数组中的元素,并且将忽略右侧数组中的匹配元素。
答案 1 :(得分:0)
您的问题来自您的操作+ =。
如果$ ticket_item_types是一个数组,你应该使用array_push。
否则,
$ ticket_item_types = array(val_paperworkticket => 19,val_disposal => 9,comment => 22,loadtime => 20,bbls => 23,disposalticketno => 46,load_reviewed => 31) ;
应该删除问题。