开发者

PHP: Show directory NAME and not a period (".")

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜