hi i have to type of string
like

http://localhost/galaxy/galaxy/register.php
and
http://localhost/galaxy/galaxy/register.php?id=1
or
http://localhost/galaxy/galaxy/register.php?id=1&err=no

and i want to find "register.php" as out put

can any one help me

thanks

Member Avatar for diafol
$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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.