1040 次
1 に答える
1
http://es2.php.net/manual/en/functions.user-defined.phpから:
PHP のすべての関数とクラスにはグローバル スコープがあります。関数内で定義されていても関数の外で呼び出すことができ、その逆も可能です。
PHP は関数のオーバーロードをサポートしておらず、以前に宣言された関数を未定義または再定義することもできません。
ov3rfly_replace_include_blank
を呼び出すたびにfunctionが宣言されてmy_wpcf7_form_elements
おり、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');
于 2012-11-15T11:27:53.767 に答える