Home  »  CodeLibrariesProgrammingSnippetsTechnology   »   Check if Folder Exists Using PHP

Check if Folder Exists Using PHP

Posted: May 11, 2022 | by Michael Bright

Use this code snippet to check if folder exists using PHP.

$directory = "/path/to/folder/";

if ( !file_exists( $directory ) ) {

   // create the directory
   mkdir($directory, 0755, true);

   // do something with the directory  

} else {

   // directory exists so do something with the it


Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.