What potential issues could arise from using the file_exists function in PHP for folder creation?

Using the file_exists function in PHP for folder creation can lead to race conditions where another process creates the folder after the file_exists check but before the folder creation. To solve this issue, it's recommended to use the mkdir function directly, which atomically creates the folder if it doesn't exist.

$folderPath = 'path/to/folder';

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