如何在Laravel 5中访问刀片中的URL段?

如何在Laravel 5中访问刀片中的URL段?

问题描述:

我有一个网址:http://localhost:8888/projects/oop/2

我要访问第一段-> projects

I want to access the first segment --> projects

我尝试过

<?php echo $segment1 = Request::segment(1); ?>

刷新页面时,我的视图中看不到任何内容.

I see nothing print out in my view when I refresh my page.

任何帮助/建议将不胜感激

Any helps / suggestions will be much appreciated

尝试一下

{{ Request::segment(1) }}