3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by diafol
0
$url = 'http://localhost/galaxy/galaxy/register.php';
$string = basename($url); //will store "register.php"

$url = 'http://localhost/galaxy/galaxy/register.php?p=w';
$string = basename($url); //will store "register.php?p=w"

If you just want the filename without the querystring:

$url = 'http://localhost/galaxy/galaxy/register.php?p=w';
$parray = parse_url($url); //will store bits of the URL as an array
$string = basename($parray['path']); //should store 'register.php'

IMPT: parse_url usually only works with URLs (absolute).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.