php fopen() function


  Translation results:

UK[ˈəʊpən] US[ˈoʊpən]

adj.Open, open; open, public; frank; room for discussion

vt.& vi. (Open) to open; to start; to unfold; to start

n.Open; outdoors, in the wild; in the open

vi.To open; to display, to appear

vt.Open; Open; open for business; unveil (a building)

Third person singular: opens Present participle: opening Past tense: opened Past participle: opened

php fopen() functionsyntax

Function:Open a file or URL.

Syntax: fopen(filename,mode,include_path,context)

Parameters:

ParameterDescription
filename Required. Specifies the file or URL to open.
mode Required. Specifies the type of access required to this file/stream.
include_path Optional. If you also need to retrieve files in include_path, you can set this parameter to 1 or TRUE.
context Optional. Specifies the environment for a file handle. Context is a set of options that can modify the behavior of the stream.

Description: fopen() binds the name resource specified by filename to a stream. If filename is of the form "scheme://...", it is treated as a URL and PHP will search for a protocol handler (also called a wrapper protocol) to handle the scheme. If the wrapper protocol has not been registered for the protocol, PHP will emit a message to help check for potential problems in the script and proceed with filename as if it were a normal filename. If PHP thinks that filename specifies a local file, it will try to open a stream on that file. The file must be accessible to PHP, so you need to confirm that the file access permissions allow this access. If safe mode or open_basedir is activated further restrictions apply. If PHP thinks that filename specifies a registered protocol, and the protocol is registered as a network URL, PHP will check and confirm that allow_url_fopen has been activated. If it is closed, PHP will issue a warning and the call to fopen will fail.

php fopen() functionexample

<?php
$file = fopen("./test.txt","r");
?>

Home

Videos

Q&A