Re: neubie seeking answers
| From: | Richard Quadling | Date: | Thu, 31 Mar 2011 16:30:15 +0000 |
| Subject: | Re: neubie seeking answers | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312163@lists.php.net to get a copy of this message | ||
On 31 March 2011 17:24, Kirk Bailey <kbailey@howlermonkey.net> wrote:
> I need to extract the name of the subdirectory a page lives in to use in the
> title for that page. This will be returned as a string to echo to the output
> stream. Now how the heck do I do that?!?
__DIR__ is the name of the directory that the __FILE__ resides in.
basename(__DIR__) will give you the directory at the end of the path
that this __FILE__ is in.
So, for ...
C:\PHP\Scripts\script.php
<?php
echo __FILE__, PHP_EOL, __DIR__, PHP_EOL, basename(__DIR__);
?>
will show
C:\PHP\Scripts\script.php
C:\PHP\Scripts
Scripts
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY