get url segment in php

Solutions on MaxInterview for get url segment in php by the best coders in the world

showing results for - "get url segment in php"
Rafaela
02 Mar 2016
1$uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
2$uri_segments = explode('/', $uri_path);
3
4echo $uri_segments[0]; // for www.example.com/user/account you will get 'user'