CodesJava

Easy learning with example program codes

PHP Open File


PHP Open File

To open a file in PHP, fopen() function is used. In general, fopen() function accepts two parameters:

Filename:  This parameter specifies the name of the file to be opened.

Mode: This parameter specifies the mode in which the file should be opened.

Syntax:

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

OR

resource fopen ( string $filename , string $mode )

MODES of fopen function:

$mode MODE DESCRIPTION
r Read only mode Pointer starts from the beginning of the file.
w Write only mode Overwrites the existing file or creates a new file if it doesn’t exist. Pointer starts from the beginning of the file.
a Write only mode Continues writing in the existing file or creates a new file if it doesn’t exist. Pointer starts from the end of the file.
x Write only mode Creates a new file if it doesn’t exist or returns FALSE if the file already exists. Pointer starts from the beginning of the file.
c Write only mode Creates a new file if it doesn’t exist or does nothing if the file already exists. Pointer starts from the beginning of the file.
r+ Read Write mode Pointer starts from the beginning of the file.
w+ Read Write mode Overwrites the existing file or creates a new file if it doesn’t exist. Pointer starts from the beginning of the file.
a+ Read Write mode Continues writing in the existing file or creates a new file if it doesn’t exist. Pointer starts from the end of the file.
x+ Read Write mode Creates a new file if it doesn’t exist or returns FALSE if the file already exists. Pointer starts from the beginning of the file
c+ Read Write mode Creates a new file if it doesn’t exist or does nothing if the file already exists. Pointer starts from the beginning of the file.

 

Posted in PHP   


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki