Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Gilles Ganault
August 3, 2010, 11:39 am
rate this thread
The following code returns the full URL of the current page:
However, I need to strip the filename:
Before using a regex to do this, I wanted to check if PHP doesn't
already have a built-in function for this, ie. the reverse of
basename(). dirname() removes the protocol + IP.
Re: Simplest way to strip filename from full URL?
For those looking for the same thing:
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
$path_parts = pathinfo(getURLBaseName());
print $path_parts['dirname'] . "<p>";
- » How to create a password protection and expires it?
- — Next thread in » PHP Scripting Forum