What is the function fopen() used for in PHP?
The fopen() function in PHP is used to open a file or URL and return a file pointer that can be used to read, write, or append to the file. It allows you to work with files in various modes such as read, write, append, etc. This function is essential for file handling operations in PHP.
$file = fopen("example.txt", "r");
if ($file) {
// File operations can be performed here
fclose($file);
} else {
echo "Unable to open file.";
}