ehi*_*ime 0 php lambda anonymous-function
嘿家伙我搞砸了我的Lambda,似乎我的匿名函数没有得到上面的变量,
进入的一些变革是
print_r($cacheTypes);
print_r($servers);
Array
(
[concreter] => on
[config] => on
)
Array
(
[0] => dev-www.domain.com
)
Run Code Online (Sandbox Code Playgroud)
功能是
$urls = array_walk($servers,
create_function('&$n',
'$n = "http://{$server}/".($vcpParam
? "flush-file-cache"
: "flushFileCache.php"
)."?tags=".implode("-", array_keys($cacheTypes));'
)
);
Run Code Online (Sandbox Code Playgroud)
错误是
Warning: array_keys() expects parameter 1 to be array, null given
Warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed
Run Code Online (Sandbox Code Playgroud)
非常感谢.我很肯定它没有认识到我正在输入的变量,但我不确定为什么
您可以使用
$urls = array_map(function ($var) use($cacheTypes, $vcpParam) {
return "http://{$var}/" . ($vcpParam ? "flush-file-cache" : "flushFileCache.php") . "?tags=" . implode("-", array_keys($cacheTypes));
}, $servers);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1001 次 |
| 最近记录: |