In this tutorial we will go through the display of the creative php folder if it does not exist. you can understand the concept of php create directory when you are not there. we will help you provide an example of php code to create a guide when you are not. This article contains details for creating a guide if there is no php. So, let's follow a few steps to create an example of a php make directory if we don't.

Sometimes, we need to create a directory from php code. for example if you store photos in a folder phone then you don't have to log in to the server and then you have to write a code to create a powerful folder using php code. So, here I will give you a simple example of how to create a folder if it does not exist.

Example 1

Sometimes, we need to create integrated links defined in the pathname. so in this example, i will give you how to do it in php. mkdir () function has a third argument that allows you to create a built-in folder. you must pass the TRUTH. Let's look at a clear example:

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

Example 2

In this example, we will use is_dir () and mkdir () to create a directory if you do not exist. is_dir () will help check whether the folder is exited or not and mkdir () will help to create a new folder.

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