What is the correct syntax for using the fopen() function in PHP?

When using the fopen() function in PHP to open a file, it is important to provide the correct file path and mode as parameters. The file path should include the file name and extension, and the mode specifies how the file should be opened (e.g. read, write, append). Make sure to handle potential errors that may occur when opening the file.

$file = fopen("example.txt", "r") or die("Unable to open file!"); // Opens example.txt in read mode
// Perform operations on the file
fclose($file); // Close the file when finished