Create Directory If It Doesn’t Exist in PHP.

if you want to create folder if not exist. you can understand a concept of php create directory if not exists. I am giving you example of php code to create directory if not exists.

I am explaining you, how to create directory if not exist php. In example, we will use is_dir() and mkdir() to create directory if does not exist. is_dir() will help to check if folder is exit or not and mkdir() will help to create new folder. let’s see example :

<?php
  
$directory_name = 'images';
   
/* Check if the directory already exists. */
if(!is_dir($directory_name)){
    /* Directory does not exist, so lets create it. */
    mkdir($directory_name, 0755);
}
  
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

6 + 2 =