jimfog Posted April 7, 2014 Share Posted April 7, 2014 Suppose we have a url like this: http://localhost/Appointments/Administrator/events.php/219 IS there a way some PHP code can "grab" that 219 above? I think that the above URL is RESTFULL. Nonetheless in the backend I do not have a REST interface. GET will not work here-the structure of the URL will not "allow" it. So, is there a way PHP can "grab" that 219 or I should change the structure of the URL. I could go straight for the second option but it is not so easy as you might think. Link to comment Share on other sites More sharing options...
jimfog Posted April 7, 2014 Author Share Posted April 7, 2014 $_SERVER['REQUEST_URI'] is a good starting point.It grabs the URL submitted. But how am I going to separate from the URI the number after events.php...which can be any number,it is just in this example that it is 219. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 7, 2014 Share Posted April 7, 2014 Split the URL on slashes and get the last element. Link to comment Share on other sites More sharing options...
jimfog Posted April 8, 2014 Author Share Posted April 8, 2014 Split the URL on slashes and get the last element. I did that using strtok unless you have to suggest a better way. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 8, 2014 Share Posted April 8, 2014 I would probably use explode and array_pop. Link to comment Share on other sites More sharing options...
jimfog Posted April 11, 2014 Author Share Posted April 11, 2014 I used explode and end after all. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now