📜  在 php 代码示例中获取 url 段

📅  最后修改于: 2022-03-11 14:54:05.780000             🧑  作者: Mango

代码示例1
$uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri_segments = explode('/', $uri_path);

echo $uri_segments[0]; // for www.example.com/user/account you will get 'user'