Jump to content

HOWTO: grab filename from address ...


bsamson

Recommended Posts

Hello ...
I have the following URL:
http://www.mydomainname.com/about.php

I would like to find out how to grab just the [i]about.php[/i] and store it in $pgfile.

The only other thing is occasionally there are variables that get passed through the URL, for example:
http://www.mydomainname.com/about.php?r=4&yu-8

Even with the above case I would like to be able to grab just the [i]about.php[/i] and store it in $pgfile.

Any assistance would be greatly appreciated! Thanks in advance!

 
Link to comment
Share on other sites

Thanks for the help. Here's what I came up w/ for code:

[code]<?

$pgfile = basename($REQUEST_URL);

echo $pgfile;

?>[/code]

Now this works in grabbing the [i]about.php[/i] ...

But, if I have this url:
http://www.mydomainname.com/about.php?var1=blah&var=blah

it grabs [i]about.php?var1=blah&var=blah[/i] in $pgfile ...

Now the url doesnt always have the variables ... but when it does I would like for it to just grab about.php. Any suggestions how I can get this to work? Thanks again in advance!
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.