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.


fopen($file, $mode, $include_path, $context);

Example test.txt

this is simple text file
$file = fopen("test.txt", 'r');
or die("File does not exist");
$result = fgets($file );
echo $result ;


this is simple text file

Reference: PHP fopen() function

Related Article