love
love

Reputation: 1391

Get php self and GET variables

$from = $_SERVER['REQUEST_URI'];

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

How to get clients.php?action=sendbook&issue=29 only? Thank you!

Upvotes: 1

Views: 3132

Answers (2)

Jason Durbin
Jason Durbin

Reputation: 3477

 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];

Upvotes: 1

Ben
Ben

Reputation: 57247

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

or even easier

basename($from);

Upvotes: 3

Related Questions