Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 警告:内爆():第2040行中传递的参数无效_Php_Wordpress - Fatal编程技术网

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

当我在(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_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
}