Php &引用;致命错误:无法重新声明";“在改变时”---&引用;标题<;选择>;联系人表单7函数中的元素

Php &引用;致命错误:无法重新声明";“在改变时”---&引用;标题<;选择>;联系人表单7函数中的元素,php,wordpress,preg-match,contact-form-7,add-filter,Php,Wordpress,Preg Match,Contact Form 7,Add Filter,这是指向测试站点的url- 我有这个功能,在 但我想这不是问题所在。。函数被调用两次,因为有两种形式。。我怎样才能克服这个问题 非常感谢。来自: PHP中的所有函数和类都具有全局作用域-它们可以是 在函数外部调用,即使它们是在函数内部定义的,反之亦然 反之亦然 PHP不支持函数重载,也不可能 取消定义或重新定义以前声明的函数 函数ov3rfly\u replace\u include\u blank每次调用my\u wpcf7\u form\u元素时都会被声明,PHP不支持函数重载,因此出现错误

这是指向测试站点的url-

我有这个功能,在

但我想这不是问题所在。。函数被调用两次,因为有两种形式。。我怎样才能克服这个问题

非常感谢。

来自:

PHP中的所有函数和类都具有全局作用域-它们可以是 在函数外部调用,即使它们是在函数内部定义的,反之亦然 反之亦然

PHP不支持函数重载,也不可能 取消定义或重新定义以前声明的函数

函数
ov3rfly\u replace\u include\u blank
每次调用
my\u wpcf7\u form\u元素时都会被声明,PHP不支持函数重载,因此出现错误。由于所有PHP函数都具有全局作用域,因此即使它们在函数外部定义,也可以在函数内部调用它们。尝试:

function ov3rfly_replace_include_blank($name, $text, &$html) {
        $matches = false;
        preg_match('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $html, $matches);
        if ($matches) {
            $select = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $matches[0]);
            $html = preg_replace('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $select, $html);
        }
    }

function my_wpcf7_form_elements($html) {
    ov3rfly_replace_include_blank('c_age', 'גיל', $html);
    ov3rfly_replace_include_blank('c_area', 'איזור', $html);
    ov3rfly_replace_include_blank('c_type', 'סוג ביטוח', $html);
    ov3rfly_replace_include_blank('c_area', 'איזור', $html);
    ov3rfly_replace_include_blank('c_cartype', 'סוג רכב', $html);
    ov3rfly_replace_include_blank('c_manifacture', 'יצרן', $html);
    ov3rfly_replace_include_blank('c_manifactureyear', 'שנת יצור', $html);
    ov3rfly_replace_include_blank('c_driversage', 'גיל הנהג', $html);
    ov3rfly_replace_include_blank('c_prevent', 'שלילות', $html);
    ov3rfly_replace_include_blank('c_claim', 'תביעות', $html);

    return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
函数ov3rfly\u replace\u包括\u blank($name、$text和$html){
$matches=false;
preg_match('/]*>(.*)/iU',$html,$matches);
如果($匹配){
$select=str_replace('--','.$text'',$matches[0]);
$html=preg_replace('/]*>(.*)/iU',$select,$html);
}
}
函数my_wpcf7_form_元素($html){
ov3rfly_replace_包括空白('c_age','c•uיuל',$html);
ov3rfly_replace_包括_blank('c_area'、'cייור'、$html);
ov3rfly(替换)包括(空白)(c)类型(c)(type)(c)(type)),(c)(type)();
ov3rfly_replace_包括_blank('c_area'、'cייור'、$html);
ov3rfly_replace_包括_blank('c_cartype'、'c••ר•ב'、$html);
ov3rfly_替换_包括_blank('c_manifacture'、'cצרן'、$html);
ov3rfly_replace_包括_blank('c_manifactureyear'、'cנתיצור'、$html);
ov3rfly(替换)包括(空白)("c)驱动器页","c"驱动器页","c"驱动器页","c"html",;
ov3rfly_replace_包括_blank('c_prevent'、'cל㜑㜍ת'、$html);
ov3rfly(替换)包括(空白)("索赔","索赔","替换","html";;
返回$html;
}
添加过滤器(“wpcf7形式元素”、“我的wpcf7形式元素”);
来自:

PHP中的所有函数和类都具有全局作用域-它们可以是 在函数外部调用,即使它们是在函数内部定义的,反之亦然 反之亦然

PHP不支持函数重载,也不可能 取消定义或重新定义以前声明的函数

函数
ov3rfly\u replace\u include\u blank
每次调用
my\u wpcf7\u form\u元素时都会被声明,PHP不支持函数重载,因此出现错误。由于所有PHP函数都具有全局作用域,因此即使它们在函数外部定义,也可以在函数内部调用它们。尝试:

function ov3rfly_replace_include_blank($name, $text, &$html) {
        $matches = false;
        preg_match('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $html, $matches);
        if ($matches) {
            $select = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $matches[0]);
            $html = preg_replace('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $select, $html);
        }
    }

function my_wpcf7_form_elements($html) {
    ov3rfly_replace_include_blank('c_age', 'גיל', $html);
    ov3rfly_replace_include_blank('c_area', 'איזור', $html);
    ov3rfly_replace_include_blank('c_type', 'סוג ביטוח', $html);
    ov3rfly_replace_include_blank('c_area', 'איזור', $html);
    ov3rfly_replace_include_blank('c_cartype', 'סוג רכב', $html);
    ov3rfly_replace_include_blank('c_manifacture', 'יצרן', $html);
    ov3rfly_replace_include_blank('c_manifactureyear', 'שנת יצור', $html);
    ov3rfly_replace_include_blank('c_driversage', 'גיל הנהג', $html);
    ov3rfly_replace_include_blank('c_prevent', 'שלילות', $html);
    ov3rfly_replace_include_blank('c_claim', 'תביעות', $html);

    return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
函数ov3rfly\u replace\u包括\u blank($name、$text和$html){
$matches=false;
preg_match('/]*>(.*)/iU',$html,$matches);
如果($匹配){
$select=str_replace('--','.$text'',$matches[0]);
$html=preg_replace('/]*>(.*)/iU',$select,$html);
}
}
函数my_wpcf7_form_元素($html){
ov3rfly_replace_包括空白('c_age','c•uיuל',$html);
ov3rfly_replace_包括_blank('c_area'、'cייור'、$html);
ov3rfly(替换)包括(空白)(c)类型(c)(type)(c)(type)),(c)(type)();
ov3rfly_replace_包括_blank('c_area'、'cייור'、$html);
ov3rfly_replace_包括_blank('c_cartype'、'c••ר•ב'、$html);
ov3rfly_替换_包括_blank('c_manifacture'、'cצרן'、$html);
ov3rfly_replace_包括_blank('c_manifactureyear'、'cנתיצור'、$html);
ov3rfly(替换)包括(空白)("c)驱动器页","c"驱动器页","c"驱动器页","c"html",;
ov3rfly_replace_包括_blank('c_prevent'、'cל㜑㜍ת'、$html);
ov3rfly(替换)包括(空白)("索赔","索赔","替换","html";;
返回$html;
}
添加过滤器(“wpcf7形式元素”、“我的wpcf7形式元素”);

为什么要在函数中声明函数。只需声明两个函数并从另一个调用一个,伙计!为什么要在函数中声明函数。只需声明两个函数并从另一个调用一个,伙计!
function ov3rfly_replace_include_blank($name, $text, &$html) {
        $matches = false;
        preg_match('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $html, $matches);
        if ($matches) {
            $select = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $matches[0]);
            $html = preg_replace('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $select, $html);
        }
    }

function my_wpcf7_form_elements($html) {
    ov3rfly_replace_include_blank('c_age', 'גיל', $html);
    ov3rfly_replace_include_blank('c_area', 'איזור', $html);
    ov3rfly_replace_include_blank('c_type', 'סוג ביטוח', $html);
    ov3rfly_replace_include_blank('c_area', 'איזור', $html);
    ov3rfly_replace_include_blank('c_cartype', 'סוג רכב', $html);
    ov3rfly_replace_include_blank('c_manifacture', 'יצרן', $html);
    ov3rfly_replace_include_blank('c_manifactureyear', 'שנת יצור', $html);
    ov3rfly_replace_include_blank('c_driversage', 'גיל הנהג', $html);
    ov3rfly_replace_include_blank('c_prevent', 'שלילות', $html);
    ov3rfly_replace_include_blank('c_claim', 'תביעות', $html);

    return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');