【发布时间】:2016-09-07 10:04:26
【问题描述】:
我想调用 routes.php 文件中定义的内联函数。
我已经尝试过这些代码:
Router::connect('/test', function () { return 'test';exit;});
Router::connect('/test', function () { echo 'test';exit;});
但是当我访问 localhost/cakephp/test 我得到错误:
Error: Cannot use object of type Closure as array
File: /var/www/html/massmobile/lib/Cake/Routing/Router.php
Line: 348
Notice: If you want to customize this error message, create app/View/Errors/fatal_error.ctp
在 laravel (http://www.tutorialspoint.com/laravel/laravel_routing.htm) 中我们可以从路由文件中调用内联函数。是否可以在 cakephp 中做同样的事情?
【问题讨论】:
标签: php laravel cakephp routing inline-functions