What are some best practices for handling file creation and access permissions in PHP?

When creating files in PHP, it is important to set appropriate access permissions to ensure the security and integrity of the files. This can be done using the `chmod()` function to set the desired permissions for the file.

// Create a new file
$file = fopen("newfile.txt", "w");

// Set file permissions to read, write, execute for owner, read and execute for group and others
chmod("newfile.txt", 0755);