PHP Function Reference

PHP php_user_filter filter() Method



The PHP php_user_filter::filter() method is called whenever data is read from or written to the attached stream, such as with fread() or fwrite() function.

Syntax

public php_user_filter::filter(in, out, consumed, closing)

Parameters

in Required. Specify a resource pointing to a bucket brigade which contains one or more bucket objects containing data to be filtered.
out Required. Specify a resource pointing to a second bucket brigade into which your modified buckets should be placed.
consumed Required. It must always be declared by reference, should be incremented by the length of the data which your filter reads in and alters. In most cases this means it will increment consumed by $bucket->datalen for each $bucket.
closing Required. If the stream is in the process of closing (and therefore this is the last pass through the filterchain), this parameter will be set to true.

Return Value

Returns one of three values upon completion.

  • PSFS_PASS_ON - Filter processed successfully with data available in the out bucket brigade.
  • PSFS_FEED_ME - Filter processed successfully, however no data was available to return. More data is required from the stream or prior filter.
  • PSFS_ERR_FATAL - (default) The filter experienced an unrecoverable error and cannot continue.

❮ PHP Streams Reference