samedi 18 avril 2015

How to get part from URL

Well sorry for the probably misleading title. Wasn't sure how to describe it better.


When accessing the status page I want to get the attached ID. But I don't want to use GET fields (wordpress makes /status?id=2134 to /status/?id=1234 - that's the only reason actually).


So this is my url



http://ift.tt/1H0HMG4


I want to get 1234


Okay fine. I could use something like $_SERVER["REQUEST_URI"] + trim() for example. Probably regex would be the key to get this job done since one could do something like /status/1234/foo/bar/baz/.. But I'm wondering if there is something builtin with PHP to get this part of the url.


Aucun commentaire:

Enregistrer un commentaire