I want to echo __FILE__ name without path. I just

2019-04-22 20:44发布

echo __FILE__;

gives me: C:\EasyPHP-DevServer-13.1VC9\data\localweb\projects\FOLDERNAME\index.php

I just want to get file name without its path. I want to get index.php on its own.

Any ideas?

2条回答
We Are One
2楼-- · 2019-04-22 21:05

Use pathinfo() function, then you can get filename via basename

$path_parts = pathinfo(__FILE__);

echo $path_parts['basename'];
查看更多
Evening l夕情丶
3楼-- · 2019-04-22 21:30

This will do what you want:

echo basename(__FILE__);
查看更多
登录 后发表回答