Get path folder in URL with PHP -
Get path folder in URL with PHP -
i utilize php code find url path of script page :
define("url", dirname($_server['request_uri']));
on pc 1, result url : htt://site1/abc/ :
/abc
but on pc 2, result same url :
\
don't understand why. if add together 'index.php', that's ok on pc 2
my goal create wizard installation , set url path in config file.
you may unexpected results dirname()
, see illustration in manual:
echo "2) " . dirname("/etc/") . php_eol; // 2) / (or \ on windows)
use parse_url()
instead:
$path = parse_url($_server['request_uri'], php_url_path); $path = '/'.implode('/', explode('/', ltrim($path, '/'), -1)); define("url", $path);
php url
Comments
Post a Comment