[php_man]getcwd[/php_man] returns current working directory. In a most cases your solution would work, but technicaly speaking it's not correct, as requested url does not always correspond to filesystem paths. Moreover, current working directory might be different from the directory containing your script.Grim... wrote:To be fair, he did ask the right question.jason wrote:I am sorry, but if you are going to ask the question, ask the right question.
He said:
getcwd() is one way of achieving this.SFADuncan wrote:I'm trying to isolate the directory path of the url of a current page
Stripping URL information into variables
Moderator: General Moderators
I've never had a problem with getcwd (although I haven't used that much). The only possible problem that springs to mind is if the getcwd is contained within an included file from a different directory you may get unexpected results.
Or you are running the CLI version of PHP in which case getcwd does not return the current working directory of the script (or at least that was the behaviour the last time I checked).
Or you are running the CLI version of PHP in which case getcwd does not return the current working directory of the script (or at least that was the behaviour the last time I checked).
Perhaps I picked this thread up wrong, but I did not think that the original poster was asking how to obtain the full url or any query strings.launchcode wrote: What the hell? Why mess with cwd? To get the "full" URL of the current page on your site, just combine two values:
$_SERVER['HTTP_HOST'] and either $_SERVER['PHP_SELF'] or $_SERVER['REQUEST_URI'] if you need all the query string values.
Merge the two and kick the result to parse_url.
Consider the following httpd.conf fragment:redmonkey wrote:The only possible problem that springs to mind is if the getcwd is contained within an included file from a different directory you may get unexpected results.
Code: Select all
#.....
Alias /somedir/ /local/path/to/someotherdir/
#.....