Php 警告:内爆():第2040行中传递的参数无效
当我在(woocommerce)function.php中为一个城市添加代码时,我得到了以下错误 行号2040--Php 警告:内爆():第2040行中传递的参数无效,php,wordpress,Php,Wordpress,当我在(woocommerce)function.php中为一个城市添加代码时,我得到了以下错误 行号2040--$field.=' 第2064行--$field\u html.=''$args['label']$必需的。” 如何解决此错误?$args['input\u class']和$args['label\u class']必须是数组,因此它们可能不是数组。您应该检查: add_filter( 'woocommerce_form_field_args', 'custom_form_fi
$field.='
第2064行--$field\u html.=''$args['label']$必需的。”代码>
如何解决此错误?$args['input\u class']
和$args['label\u class']
必须是数组,因此它们可能不是数组。您应该检查:
add_filter( 'woocommerce_form_field_args', 'custom_form_field_args', 10, 3 );
function custom_form_field_args( $args, $key, $value ) {
if ( $args['id'] == 'billing_city' ) {
$args = array(
'label' => __( 'Town / City', 'woocommerce' ),
'required' => TRUE,
'clear' => TRUE,
'type' => 'select',
'options' => array(
'' => ('Select City' ),
'Duliajan' => ('Duliajan' )
),
'class' => array( 'update_totals_on_change' )
);
} // elseif … and go on
return $args;
};
这里只有两个内爆()
调用。检查传递给每个对象的内容有什么问题?检查$args['input_class']和$args['label_class']是否将返回数组
if (!is_array($args['label_class']) {
// initialize to some empty array? depends on your application, what it needs to do
}