开发者

Error handling opendir

开发者 https://www.devze.com 2023-02-21 21:05 出处:网络
I always get a warming when I tried to use the opendir() but the folder does not exists. How can I handle this error, and verify if the folder exi开发者_开发知识库sts before open the directory?is_dir(

I always get a warming when I tried to use the opendir() but the folder does not exists. How can I handle this error, and verify if the folder exi开发者_开发知识库sts before open the directory?


is_dir($directory)

Returns TRUE if the filename exists and is a directory, FALSE otherwise.


You can check if the directory exists with is_dir()

if(is_dir($dir)){
    // code
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号