English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and Examples of PHP fopen() Function

PHP Filesystem Reference Manual

The fopen() function can open a file or URL. If fopen() fails, it can return false and an error message. We can hide the error output by adding " @" before the function name.

Syntax

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

The fopen() function binds a named resource to a stream specified by the file name.

Online Example

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

PHP Filesystem Reference Manual