What are the potential security risks of using Chmod777 on files like news.txt in a PHP script?

Setting the file permission to 777 (Chmod777) allows anyone to read, write, and execute the file, which can pose a significant security risk. It is not recommended to use 777 permission on files like news.txt in a PHP script as it can make the file vulnerable to unauthorized access and modification by malicious users. To mitigate this risk, it is advisable to set more restrictive file permissions based on the principle of least privilege.

// Set more restrictive file permissions on news.txt
chmod("news.txt", 0644);