array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'function.stream-bucket-prepend.php', 1 => 'stream_bucket_prepend', ), 'up' => array ( 0 => 'ref.stream.php', 1 => 'Stream Functions', ), 'prev' => array ( 0 => 'function.stream-bucket-new.php', 1 => 'stream_bucket_new', ), 'next' => array ( 0 => 'function.stream-context-create.php', 1 => 'stream_context_create', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/stream/functions/stream-bucket-prepend.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
stream_bucket_prepend — Prepend bucket to brigade
This function can be called to prepend a bucket to a bucket brigade. It is typically called from php_user_filter::filter().
brigade
brigade
is a resource pointing to a bucket brigade
which contains one or more bucket
objects.
bucket
A bucket object.
No value is returned.
Example #1 stream_bucket_prepend() examples
<?php
class foo extends php_user_filter {
protected $calls = 0;
public function filter($in, $out, &$consumed, $closing) {
while ($bucket = stream_bucket_make_writeable($in)) {
$consumed += $bucket->datalen;
if ($this->calls++ == 2) {
// This bucket will appear again before any other bucket.
stream_bucket_prepend($in, $bucket);
}
}
return PSFS_FEED_ME;
}
}
stream_filter_register('test', 'foo');
print file_get_contents('php://filter/read=test/resource=foo');
?>