Jump to content

grabbing URL data


jimfog

Recommended Posts

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

$_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

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

I used explode and end after all.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...