How can PHP functions like is_dir() and mkdir() be optimized for more efficient directory creation?

To optimize PHP functions like is_dir() and mkdir() for more efficient directory creation, it is important to minimize the number of system calls being made. This can be achieved by checking if the directory already exists before attempting to create it, reducing unnecessary operations.

$directory = 'path/to/directory';

if (!is_dir($directory)) {
    mkdir($directory, 0755, true);
}