• PHP Video Tutorials

PHP - Function fopen()



The fopen() function can open a file or URL. If fopen() fails, it can return false and an error on failure. We can hide the error output by adding an '@' in front of the function name.

Syntax

resource fopen ( string $filename , string $mode [, bool $use_include_path = FALSE [, resource $context ]] )

The fopen() function can bind named resource specified by filename to a stream.

Example

<?php
   $file = fopen("/PhpProject/sample.txt", "r");
   $file = fopen("/PhpProject/index.php", "r");
   $file = fopen("/PhpProject/sample1.txt", "wb");
?>
php_function_reference.htm
Advertisements