Back to Stream class

Method prependFilter

public mixed
prependFilter
(mixed $filterName, mixed $readWrite = STREAM_FILTER_READ, mixed $params = array())
Prepend a filter to the chain
Parameters
  • string $filterName The key name of the filter.
  • int $readWrite Optional. Defaults to STREAM_FILTER_READ.
  • array $params An array of params for the stream_filter_prepend call.
Returns
  • mixed
Since
  • 1.7.0
-
  • https://www.php.net/manual/en/function.stream-filter-prepend.php
Class: Stream
Project: Joomla

Method prependFilter - Source code

/**
 * Prepend a filter to the chain
 *
 * @param   string   $filterName  The key name of the filter.
 * @param   integer  $readWrite   Optional. Defaults to STREAM_FILTER_READ.
 * @param   array    $params      An array of params for the stream_filter_prepend call.
 *
 * @return  mixed
 *
 * @link    https://www.php.net/manual/en/function.stream-filter-prepend.php
 * @since   1.7.0
 */
public function prependFilter($filterName, $readWrite = STREAM_FILTER_READ, $params = array())
{
    $res = false;
    if ($this->fh) {
        // Capture PHP errors
        $php_errormsg = '';
        $track_errors = ini_get('track_errors');
        ini_set('track_errors', true);
        $res = @stream_filter_prepend($this->fh, $filterName, $readWrite, $params);
        if (!$res && $php_errormsg) {
            // Set the error msg
            $this->setError($php_errormsg);
        } else {
            array_unshift($res, '');
            $res[0] =& $this->filters;
        }
        // Restore error tracking to what it was before.
        ini_set('track_errors', $track_errors);
    }
    return $res;
}