开发者

Get second argument in php navigation

I am trying to grab the second argument of a URL such as this:

http://website.com/?p=2?id=ass92jdskdj92

I just want the id portion of the address. I use the following code to grab the first portion of the address:

$p = $_GET[p]; 
$remove = strrchr($p, '?'); 
$p = str_replace($remove, "", $p);

Any hints on how to get开发者_JAVA百科 the second portion?


Arguments in links are started by ? and divided by &.

That means your link should look like this:

http://website.com/?p=2&id=ass92jdskdj92

And you get them by:

$p = $_GET['p'];
$id = $_GET['id'];


First change the URL

only first argument start with ? and rest of all is append by &

u should try with

echo parse_url($url, PHP_URL_PATH);

Reference:
parse url

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜