What potential issues can arise when using mkdir to create directories in PHP, especially on Windows operating systems like Vista?

When using mkdir to create directories in PHP on Windows operating systems like Vista, potential issues can arise due to permission restrictions or invalid characters in the directory name. To solve this, you can set the correct permissions for the directory or sanitize the directory name to remove any invalid characters before creating it.

$directoryName = 'new_directory';
$directoryName = preg_replace('/[^\w\s-]/', '', $directoryName); // Remove invalid characters
mkdir($directoryName, 0777); // Create the directory with correct permissions