Check whether a directory exists in PHP

后端 未结 4 1680
暗喜
暗喜 2020-12-16 10:31

I know, I know, this sounds soo easy. But I can\'t seem to find the correct answer on the Internet.

One of the solution I found was to use i

4条回答
  •  情深已故
    2020-12-16 11:06

    Should work correctly. From is_dir() documentation:

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

    Well, anyway if it doesn't try this:

    if(file_exists($dir) && is_dir($dir))
    

    BTW. results of these functions are cached in stat cache. Use clearstatcache() to clean that cache.

提交回复
热议问题