return View::filter(function($content){
return str_replace("op","<span style='color: red'>op</span>",$content);
})->fetch("index");
这样指定字符串可以,不过我需要按某个变量替换.比如$keyword;
return View::filter(function($content){
return str_replace($keyword,"<span style='color: red'>$keyword</span>",$content);
})->fetch("index");
这样会提示Undefined variable: keyword如果闭包函数中
function($content,$keyword) 这里加上$keyword
那么会抛出
Too few arguments to function app\blog\controller\Index::app\blog\controller\{closure}(), 1 passed and exactly 2 expected
最佳答案
