为什么包含调用 stream_flush?

Why does include call stream_flush?

我写了一个流包装器,当我调用 include foo://bar 时,我的 stream_flush 实现被调用。 stream_open 被调用 rb。那么......为什么叫flush?由于文件是以只读方式打开的,如果我对 stream_flush 的理解是正确的,那么我真的无事可做,但如果我的理解是正确的,那么它不会首先被调用。

编辑:因为这得到了 "unclear what you are asking" 接近的投票:真正的问题是,当在只读文件上调用它时,我应该在 stream_flush 实现中做什么?

stream_flush was 通常在关闭流时调用。我真的不明白为什么总是这样做。写了一些东西才有意义,但什么都没写(也就是只读)就没有意义了。

在代码中注明了/* make sure everything is saved */,如果有什么写的话就完全没问题。

已通过 http://git.php.net/?p=php-src.git;a=commitdiff;h=6ad9cd5367734276d624d6d2a03406ed0d0cd08b (PHP 7.0 tree) ... stream_flush now only ever is called when either explicitly flushed or upon close while something was written, but not yet flushed. Also clarified in docs http://svn.php.net/viewvc/phpdoc/en/trunk/reference/stream/streamwrapper/stream-flush.xml?r1=337084&r2=337083&pathrev=337084 修复(可能要到周五才能重建所有文档)。