Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我的目录中有 image.jpg。
并假设我知道的唯一细节是我有一个文件名 name = 'image' 但我不知道它的扩展名是什么。
是否有 PHP 函数可以知道文件的扩展名?
您可以通过以下方式找到文件glob:
glob
$matching = glob('/some/directory/' . $name . '.*');
http://php.net/manual/en/function.pathinfo.php显示您需要的所有内容、路径、文件名和扩展名。