获取php self和GET变量

时间:2010-10-28 04:41:51

标签: php

$from = $_SERVER['REQUEST_URI'];

echo /marketing/clients.php?action=sendbook&issue=29

如何仅获得clients.php?action=sendbook&issue=29? 谢谢!

2 个答案:

答案 0 :(得分:3)

$temp = explode("/",$from);
$temp = end($temp);

甚至更容易

basename($from);

答案 1 :(得分:1)

 echo $_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'];
 // or (if you have to use $from)
 $from = $_SERVER['REQUEST_URI'];
 $url = parse_url($from);
 echo $url['path']."?".$url['query'];
 //or
 $url = explode("/",$from);
 echo $url[1];