我有一个很长的文件路径,例如,
http://www.mysite.com/local/views/templates/home.php
我使用 basename()
只返回文件本身,
<?php echo basename($file);?>
但是我怎样才能返回没有文件基本名称的文件路径,如下面的行所示?
http://www.mysite.com/local/views/templates/
最佳答案
您正在寻找dirname
(尽管它没有留下尾部斜线)。
关于php - 如何返回没有文件基本名称的文件路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897082/