How do I get PHP to return the NAME of the current directory that the php file is in, and not "."?
What we're doing is having one master index file copied to each folder and presenting the 开发者_开发问答images it finds in each folder necessarily. Now we need to remind the user what folder they're currently in!
Thanks
Use basename(realpath('.'))
, See:
- realpath()
- basename()
use __DIR__
or, before PHP 5.3, dirname(__FILE__)
You can use the realpath
function for that.
Have you tried getcwd
<?php
// current directory
echo getcwd();
Or realpath as mentioned below. realpath
is generally more useful as you are not restricted to the current working directory.
精彩评论