略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: stream_bucket_prepend

2024-11-14

stream_bucket_prepend

(PHP 5, PHP 7, PHP 8)

stream_bucket_prepend Prepend bucket to brigade

说明

stream_bucket_prepend(resource $brigade, object $bucket): void

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.

返回值

没有返回值。

范例

示例 #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');
?>
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.stream-bucket-prepend.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3