过去几天我一直在玩Silex。我无法理解下面的代码片段如何工作。PHP Silex微框架语法解释
我对不感兴趣什么它确实,而是如何它做到了。
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
$app->get('/foo', function (Application $app, Request $request) {
$subRequest = Request::create('/', ...);
$response = $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false);
return $response;
});
我弄糊涂各地
function (Application $app, Request $request)
从我的理解这是一个匿名函数被调用作为参数传递给$ APP-> get方法。这个匿名函数中的两个参数是如何工作的?具体是什么:
Application $app, Request $request
?
谢谢!
你认为它有什么作用?你有没有看过以前看起来像这样的东西?也许在类方法或其他功能? – ircmaxell 2013-05-08 20:10:17
我有我的怀疑,但不知道是否可以在OOP中使用typehinting。 – Carvefx 2013-05-09 20:43:53