PHP : Create Directory if not available

In this tutorial learn how to create directory using php if directory not created without using command.

/*
*  Create Directory if not available 
*/ 
function createDirectory(string $directory): bool
    {
        return !(!\is_dir($directory) && !@\mkdir($directory, 0777, true) && !\is_dir($directory));
    }

echo createDirectory("demo");


Using the mkdir() method can create a new function and check directory using is_check().



No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...