获取PHP中URL的最后一个参数 [英] Get last parameter of url in php

查看:477
本文介绍了获取PHP中URL的最后一个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
提取URI上的最后一段

Possible Duplicate:
Extracting the last segment on an URI

我想获取url的最后一个参数,例如.

I want to get the last parameter of the url for eg.

http://www.youtube.com/embed/ADU0QnQ4eDs

我有一个完整的网址,如上,我只想使用 PHP 获得最后一个参数,即 ADU0QnQ4eDs

I have a full url like above and i want to get only last parameter with the PHP which is ADU0QnQ4eDs

请帮助

推荐答案

像这样吗?

echo end(explode("/", $url));

如果启用了严格的错误报告,则将引发错误. 为了避免这种情况,请像这样将它们分开:

This will throw an error if strict error reporting is enabled. To avoid this, split them up like this:

$parts = explode("/", $url);
echo end($parts);

这篇关于获取PHP中URL的最后一个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆