这是针对变量范围的。
A variable declared within a function has a LOCAL SCOPE and can only be accessed within that function
A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside a function:
$meinungen = Test; // is in global scope
function wpseo_set_title_callback($input) {
if (is_single()) {
return \'\'. $meinungen . \'\'. $input . \' \'. $input . \'\'; // now $meinungen local variable which you don not assign value.
}
// return default
return $input; }
要调用值,只需在函数中使用put global
function wpseo_set_title_callback($input) {
if (is_single()) {
global $meinungen;
return \'\'. $meinungen . \'\'. $input . \' \'. $input . \'\';
}
// return default
return $input;
}