如何返回文件';s路径而不包含文件';的基本名称


how to return the file's path without the file's basename?

我有一个很长的文件路径,例如

http://www.mysite.com/local/views/templates/home.php

并且我使用basename()仅返回文件本身,

<?php echo basename($file);?>

但是,如果没有文件的基本名称(如下面的行),我如何返回文件的路径?

http://www.mysite.com/local/views/templates/

您正在查找dirname(尽管它没有留下斜杠)。

在实际操作中查看