Kann mkdir fehlschlagen und trotzdem true liefern?

The mkdir function in PHP can fail if there are permission issues or if the directory already exists. However, it will still return true if the directory was successfully created. To handle this, you can check the return value of mkdir to determine if the directory was created successfully or not.

$dir = '/path/to/directory';

if (!file_exists($dir) && !mkdir($dir, 0777, true)) {
    echo 'Failed to create directory';
} else {
    echo 'Directory created successfully';
}