How to access URL segment(s) in blade in Laravel 5?

cyber8200 picture cyber8200 · Aug 5, 2015 · Viewed 115.7k times · Source

I have a url : http://localhost:8888/projects/oop/2

I want to access the first segment --> projects

I've tried

<?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

Answer

Aniket Singh picture Aniket Singh · Aug 5, 2015

Try this

{{ Request::segment(1) }}