Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel Blade如何使用@show action打印uri_Php_Laravel_Laravel Blade - Fatal编程技术网

Php Laravel Blade如何使用@show action打印uri

Php Laravel Blade如何使用@show action打印uri,php,laravel,laravel-blade,Php,Laravel,Laravel Blade,在我看来,我想像这样打印控制器uriShopController@show 设置var$controller='ShopControll' 在视图中: action($controller.'@show',$id) ErrorException in UrlGenerator.php line 603: Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not def

在我看来,我想像这样打印控制器uri
ShopController@show

设置var
$controller='ShopControll'

在视图中:

action($controller.'@show',$id)
ErrorException in UrlGenerator.php line 603:
Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not defined. 
action('ShopController@show',$id)
http://example.com/show/1
但出现了一些错误:

action($controller.'@show',$id)
ErrorException in UrlGenerator.php line 603:
Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not defined. 
action('ShopController@show',$id)
http://example.com/show/1
工作正常,输出为:

action($controller.'@show',$id)
ErrorException in UrlGenerator.php line 603:
Action App\Http\Controllers\ShopController<?php echo $__env->yieldSection(); ?> not defined. 
action('ShopController@show',$id)
http://example.com/show/1

那么,有什么区别呢?

@show是一个blade指令,blade解析它。如果要将其显示为一节,请检查这里的示例

@section('sidebar')
            This is the master sidebar.
@show

您可以像这样修改您的方法

action($controller,'show',$id)

对于Laravel>=5.3,您可以使用以下组合:

对于早期版本,我认为(仅在5.3上再次测试),这也应该适用:

{{ @action($controller.'@show', ['id' => $id])}}