On Friday, January 2, 2004, at 09:30 AM, Dino Costantini wrote:

i have a file name with the path ex food/italy/pizza/margherita.php. how can i obtain the name of the file in this case "margherita.php" i know there is a function, but i don't remember it.
thx

<?=$_SERVER['PHP_SELF']?> ... will echo something like... food/italy/pizza/margherita.php

If you need just margherita.php, then you can explode() the string on '/', and take the last element:

<?
$pathBits = explode('/',$_SERVER['PHP_SELF']);
echo $file = $pathBits[count($pathBits)-1];
?>

To look for other useful vars, try <pre><? print_r($_SERVER); ?></pre>

Justin French

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to