...

View Full Version : $_SERVER['SCRIPT_NAME'] but only the folder



curb
08-22-2006, 07:35 PM
$domain = $_SERVER['HTTP_HOST'];
$path = $_SERVER['SCRIPT_NAME'];
$url = "http://" . $domain . $path;
echo "$url";

I'm trying to call the url without the current filename.
ex: http://localhost/folder/index.php

But I want it to just show the url without the index.php like this:
ex: http://localhost/folder/

Fumigator
08-22-2006, 08:39 PM
You can use pathinfo($_SERVER['SCRIPT_URI']); and/or parse_url($_SERVER['SCRIPT_URI']); to dump all the file info to an array and then pick and choose the elements you want.

mlseim
08-22-2006, 08:41 PM
how about something like this:

$domain = $_SERVER['HTTP_HOST'];
$path = $_SERVER['SCRIPT_NAME'];
$basename = basename($_SERVER['SCRIPT_NAME']);
$url = "http://" . $domain . $path;
$newurl = str_replace($basename, "", $url);
echo "$newurl";

curb
08-23-2006, 08:32 PM
thanks mlseim, it works.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum