What potential issue should be considered when creating directories dynamically in PHP?

One potential issue to consider when creating directories dynamically in PHP is the permissions of the parent directory. If the parent directory does not have the appropriate write permissions, the script will not be able to create the new directory. To solve this issue, you can use the `mkdir()` function in PHP and set the correct permissions using the `chmod()` function.

$parentDir = 'path/to/parent/directory';
$newDir = 'new/directory';

if (!file_exists($parentDir)) {
    mkdir($parentDir, 0777, true);
}

if (!file_exists($parentDir . '/' . $newDir)) {
    mkdir($parentDir . '/' . $newDir, 0777);
}