What are some potential pitfalls when trying to create a file using PHP?

One potential pitfall when creating a file using PHP is not checking if the file already exists before attempting to create it. This can lead to errors or overwriting existing files unintentionally. To avoid this, you should use functions like `file_exists()` to check if the file already exists before creating it.

$filename = 'example.txt';

if (!file_exists($filename)) {
    $file = fopen($filename, 'w');
    fclose($file);
    echo 'File created successfully.';
} else {
    echo 'File already exists.';
}