What is the difference between using mkdir() in PHP and mkdir -p [path] in Linux for creating directories?

The main difference between using mkdir() in PHP and mkdir -p [path] in Linux for creating directories is that mkdir() in PHP is a function that creates a single directory at a time, while mkdir -p [path] in Linux is a command that creates a directory along with any necessary parent directories that do not exist. To replicate the functionality of mkdir -p [path] in Linux in PHP, you can use the following code snippet:

<?php
function mkdir_recursive($path)
{
    if (!is_dir($path)) {
        mkdir_recursive(dirname($path));
        mkdir($path);
    }
}

mkdir_recursive('/path/to/directory');
?>