Question: I want to create a directory if it does not exist already.

Is using the `is_dir` function enough for that purpose?

```
if ( !is_dir( $dir ) ) {
    mkdir( $dir );       
}

```

Or should I combine `is_dir` with `file_exists`?

```
if ( !file_exists( $dir ) && !is_dir( $dir ) ) {
    mkdir( $dir );       
} 

```

Answer: 
```
$year = date("Y");   
$month = date("m");   
$filename = "../".$year;   
$filename2 = "../".$year."/".$month;

if(file_exists($filename)){
    if(file_exists($filename2)==false){
        mkdir($filename2,0777);
    }
}else{
    mkdir($filename,0777);
}

```
i think this is fast solution for dir check.

```
$path = realpath($Newfolder);
if (!empty($path)){
   echo "1";
}else{
   echo "0";
}

```