[ACCEPTED]-PHP - Getting Current URL-php

Accepted answer
Score: 50
$query = $_SERVER['PHP_SELF'];
$path = pathinfo( $query );
$what_you_want = $path['basename'];

Voila.

0

Score: 41

This will get you the name of the file that 4 was requested (based on the URL invoked, not 3 real location of the file - just in case 2 you are using mod_rewrite):

$filename = basename($_SERVER['REQUEST_URI']);

For both http://www.example.com/testing01.php and 1 http://www.example.com/x/y/z/testing01.php will give you:

testing01.php
Score: 3
$file = $_SERVER["SCRIPT_NAME"];
$break = explode('/', $file);
$pfile = $break[count($break) - 1]; 

0

More Related questions