fopen () PHP Function
Definition: Opens a file in PHP
to read, write, or rewrite to. It
is phrased as fopen ( filename,
mode)
Modes:
r - Reading
only, beginning of file
r+ - Reading
and writing, beginning of file
w - Writing
only, beginning of file
w+ - Writing
and reading, beginning of file
a - Writing
only, end of file
a+ - Writing
and reading, end of file
x - Create
and open for writing only,
beginning of file
x+ - Create
and open for reading and
writing, beginning of file
If the file does not exist and
you use w, w+, a or a+ it will
attempt to create the file.
Examples: Some
examples of opening different
files:
<?php
$a = fopen("/home/files/yourfile.txt",
"r");
$b = fopen("yourfile.gif",
"w");
$c = fopen("http://www.yoursite.com/",
"r");
$d = fopen("ftp://user:password@yoursite.com/yourfile.txt",
"w");
?>
|
|
|
|
|