这里的主要应用:
$test=array();
invoke_hooks("hook",$test);
钩子的两个功能:
function first_hook(&$a = array()) {
$a[40] = "1";
}
function second_hook(&$a = array()) {
$a[300] = "2";
}
function invoke_hooks($hook_name) {
$args = func_get_args();
array_shift($args);
$functions = get_defined_functions();
foreach ($functions as $f) {
if (substr($f, -strlen($hook_name)) === $hook_name) {
call_user_func_array($f, &$args);
}
}
}
想法是:
$test[40]=="1";
$test[300]=="2";
我该怎么做?