What are the different attributes for the fopen function in PHP and how do they affect file handling?

The different attributes for the fopen function in PHP are the mode parameter, which determines how the file should be opened (read, write, append, etc.), and the context parameter, which allows additional options to be specified. These attributes affect file handling by determining the permissions and actions that can be performed on the file.

$file = fopen("example.txt", "r"); // Opens the file for reading
if ($file) {
    // File handling code here
    fclose($file); // Close the file when done
} else {
    echo "Error opening file";
}