note 49486 added to function.basename
| From: | KOmaSHOOTER at gmx dot de | Date: | Sun, 30 Jan 2005 00:24:16 +0000 |
| Subject: | note 49486 added to function.basename | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84185@lists.php.net to get a copy of this message | ||
If you want the current path where youre file is and not the full path then use this :)
<?php
echo('dir = '.basename (dirname($_SERVER['PHP_SELF']),"/"));
// retuns the name of current used directory
?>
Example:
www dir: domain.com/temp/2005/january/t1.php
<?php
echo('dirname
<br>'.dirname($_SERVER['PHP_SELF']).'<br><br>');
// returns: /temp/2005/january
?>
<?php
echo('file = '.basename ($PHP_SELF,".php"));
// returns: t1
?>
if you combine these two you get this
<?php
echo('dir = '.basename (dirname($_SERVER['PHP_SELF']),"/"));
// returns: january
?>
And for the full path use this
<?php
echo(' PHP_SELF
<br>'.$_SERVER['PHP_SELF'].'<br><br>');
// returns: /temp/2005/january/t1.php
?>
----
Manual Page -- http://www.php.net/manual/en/function.basename.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49486
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49486&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49486&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49486&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49486&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49486&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49486&report=yes
Search -- http://master.php.net/manage/user-notes.php