开发者

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

开发者 https://www.devze.com 2023-03-23 02:57 出处:网络
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 开发者_

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

精彩评论

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