PHP fopen() function with example
In this article, We will explain to you PHP fopen() function with example.
PHP fopen() function
The fopen() function is a built-in function of PHP. which is used to opens a file or URL. if fopen() fails, it returns false and an error on failure. so you can see our PHP file handling Function example.
Syntax
fopen($file, $mode, $include_path, $context);
Example test.txt
this is simple text file
<?PHP
$file = fopen("test.txt", 'r');
or die("File does not exist");
$result = fgets($file );
echo $result ;
fclose($file);
?>
Output
this is simple text file
Reference: PHP fopen() function