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
https://forums.phpfreaks.com/topic/28742-howto-grab-filename-from-address/
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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.