What is the recommended file permission setting when creating files using PHP scripts on a web server?

When creating files using PHP scripts on a web server, it is recommended to set the file permissions to 0644. This setting allows the owner to read and write the file, while others can only read the file. This helps to ensure security and prevent unauthorized access to the files.

$file = 'example.txt';
$data = 'Hello, World!';

// Create a new file and set the permissions to 0644
file_put_contents($file, $data);
chmod($file, 0644);