Jump to content

[SOLVED] Extract Filename from URL


mcmuney

Recommended Posts

In your example this would work.

$a = $_SERVER['PHP_SELF'];
$b = str_replace(".php","","$a");
echo $b;

The downside is when the url changes from abc.com/game.php to abc.com/directory/game.php

You would have to substract the directory bit to if that isn't the case this would do.

 

$_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.