fopen
Function • Params changed in PHP 8.0
Opens file or URL.
fopen Function synopsis
fopen(
string $filename,
string $mode,
bool $use_include_path = false,
$context = null
)
Parameters
$filename
Typestring
If $filename is of the form "scheme://...", it
is assumed to be a URL and PHP will search for a protocol handler
(also known as a wrapper) for that scheme. If no wrappers for that
protocol are registered, PHP will emit a notice to help you track
potential problems in your script and then continue as though
$filename specifies a regular file.
$mode
Typestring
The $mode parameter specifies the type of access
you require to the stream. It may be any of the following:
$use_include_path
OptionalTypeboolDefault valuefalse
The optional third $use_include_path parameter
can be set to true if you want to search for the file in the
include_path too.
$context
OptionalDefault valuenull
Changes to the fopen Function
PHP 8.0
- Parameter type added for parameter #1 (
$filename):string - Parameter type added for parameter #2 (
$mode):string - Parameter type added for parameter #3 (
$use_include_path):bool - Parameter default value added for position #3 (
$use_include_path):false - Parameter default value added for position #4 (
$context):null
fopen(
- $filename,
+ string $filename,
- $mode,
+ string $mode,
- $use_include_path,
+ bool $use_include_path = false,
- $context
+ $context = null
) fopen Function Availability
fopen Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Future Release | Yes |
| PHP 8.5Upcoming Release | Yes |
| PHP 8.4Supported (Latest) | Yes |
| PHP 8.3Supported | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Security-Fixes Only | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |