basename 和 dirname 文件名和目录名

$path = "/home/httpd/html/index.php";
$file = basename($path);        // $file is set to "index.php"
$file = basename($path,".php"); // $file is set to "index"

dirname:

$path = "/etc/passwd";
$file = dirname($path); // $file is set to "/etc"

一个是取出目录名
一个是取出文件名

原文地址:https://www.cnblogs.com/qinqiu/p/4532891.html