我在Laravel文档中看到了这个例子:
Blade::extend(function($view, $compiler)
{
$pattern = $compiler->createMatcher('datetime');
return preg_replace($pattern, '$1<?php echo $2->format(\'m/d/Y H:i\'); ?>', $view);
});
但我似乎不太理解它,有时网上的示例包括 $3。
通过谷歌搜索,我没有找到合适的答案,感激任何帮助。
$compiler->createMatcher()
函数的代码时,我更明白它了。第一组将引用@
,然后是传递的值,以及可能存在于Blade扩展函数中的参数。 - Mohamed Mo Kawsara