[英]How to call inline function from routing (routes.php) file in cakephp 2?
我想調用一個在route.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中做同樣的事情嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.