Basename and Server Request URI
Posted: Mon May 09, 2011 12:04 pm
Hi,
I am using the following code:
echo basename($_SERVER['REQUEST_URI']);
If I navigate to http://localhost/orders/ the result I get is "orders", perfect.
If I navigate to http://localhost/findorder/ the result I get is "findorder", again perfect.
However if I navigate to http://localhost/vieworder/?id=2564 the result I get is "?id=2564".
The result I am looking for is "vieworder" but I cannot seem to find any code that will do this and still return the same for the first two examples. Does any one know of a way I can acheive this?
I am using the following code:
echo basename($_SERVER['REQUEST_URI']);
If I navigate to http://localhost/orders/ the result I get is "orders", perfect.
If I navigate to http://localhost/findorder/ the result I get is "findorder", again perfect.
However if I navigate to http://localhost/vieworder/?id=2564 the result I get is "?id=2564".
The result I am looking for is "vieworder" but I cannot seem to find any code that will do this and still return the same for the first two examples. Does any one know of a way I can acheive this?