stream_filter_prepend

FunctionParams changed in PHP 8.0

Attach a filter to a stream.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

stream_filter_prepend Function synopsis

stream_filter_prepend(
    $stream,
    string $filter_name,
    int $mode = 0,
    mixed $params = <default>
  )

Parameters

$stream

The target stream.

$filter_name

Typestring

The filter name.

$mode

OptionalTypeintDefault value0

By default, stream_filter_prepend will attach the filter to the read filter chain if the file was opened for reading (i.e. File Mode: r, and/or +). The filter will also be attached to the write filter chain if the file was opened for writing (i.e. File Mode: w, a, and/or +). STREAM_FILTER_READ, STREAM_FILTER_WRITE, and/or STREAM_FILTER_ALL can also be passed to the $mode parameter to override this behavior. See stream_filter_append for an example of using this parameter.

$params

OptionalTypemixedDefault value

This filter will be added with the specified $params to the beginning of the list and will therefore be called first during stream operations. To add a filter to the end of the list, use stream_filter_append.

Changes to the stream_filter_prepend Function

PHP 8.0

  • Parameter name of parameter #2 changed: $filtername to $filter_name
  • Parameter type added for parameter #2 ($filter_name): string
  • Parameter name of parameter #3 changed: $read_write to $mode
  • Parameter type added for parameter #3 ($mode): int
  • Parameter default value added for position #3 ($mode): 0
  • Parameter name of parameter #4 changed: $filterparams to $params
  • Parameter type added for parameter #4 ($params): mixed
  • Parameter default value added for position #4 ($params): <default>
  stream_filter_prepend(
      $stream,
-     $filtername,
+     string $filter_name,
-     $read_write,
+     int $mode = 0,
-     $filterparams
+     mixed $params = <default>
    )

stream_filter_prepend Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported 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