when I use
echo basename($_SERVER['HTTP_REFERER']);
I get
edit_property.php?id=1
Is there a way I can parse out the variable everything to the right of the ? so all that is returned is the php page
when I use
echo basename($_SERVER['HTTP_REFERER']);
I get
edit_property.php?id=1
Is there a way I can parse out the variable everything to the right of the ? so all that is returned is the php page
I typically use strtr
to do my work. But I believe others might have better solutions.
I don’t know if it’s better than strstr but parse_url comes to mind.
http://php.net/manual/en/function.parse-url.php
<?php
$url = 'http://username:password@hostname:9090/path?arg=value#anchor';
var_dump(parse_url($url));
var_dump(parse_url($url, PHP_URL_SCHEME));
var_dump(parse_url($url, PHP_URL_USER));
var_dump(parse_url($url, PHP_URL_PASS));
var_dump(parse_url($url, PHP_URL_HOST));
var_dump(parse_url($url, PHP_URL_PORT));
var_dump(parse_url($url, PHP_URL_PATH));
var_dump(parse_url($url, PHP_URL_QUERY));
var_dump(parse_url($url, PHP_URL_FRAGMENT));
?>
works great, thanks…
This returns the path also. If you just want the filename of the php script this could help
var_dump(basename($_SERVER['SCRIPT_NAME']));
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.