Jump to content

Using the REQUEST_URI statement...


mkosmosports

Recommended Posts

I have the following variable defintition : $currentt = $_SERVER['REQUEST_URI'];
echoing this gives me the current URL that is being used. However, I would like to get it to only show the name of the html page that is being used.

For example, currently if the url is "http://localhost/index.htm?g=2&h=4", and I echo $currentt I want it only to return "index.htm" not the entire url...

Does anyone know of a way that this can be done?

Thanks.
mkosmosports
Link to comment
Share on other sites

Nevermind, the below script is working for me... :D

  $full_path = getenv("REQUEST_URI"); //retrieves the full url
  $pagename = basename($full_path); //retrieves the name of the html page youre using (with or without any url parameters)....

  $currentt = substr($pagename //makes sure only the html page name getx extracted...
  , strrpos($pagename, "/")
  , strpos($pagename, ".html"));

The above variable $currentt will extract the name of the current html page thats being used and nothing but....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.