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.
当我尝试使用 opendir() 但文件夹不存在时,我总是会感到温暖。如何处理此错误,并在打开目录之前验证文件夹是否存在?
is_dir($directory)
如果文件名存在并且是目录,则返回 TRUE,否则返回 FALSE。
您可以检查目录是否存在is_dir()
is_dir()
if(is_dir($dir)){ // code }