Why does the system set file permissions to 0644 even after using chmod() in PHP?

The issue may be occurring because the system's umask value is affecting the file permissions set by chmod(). To solve this, you can explicitly set the umask value using the umask() function before calling chmod().

// Set umask value to ensure proper file permissions
umask(0);

// Set file permissions using chmod()
chmod('example.txt', 0644);