phpday 2027 - Call for Papers

stream_clear_errors

(PHP 8 >= 8.6.0)

stream_clear_errors — Discards the stored stream errors

说明

function stream_clear_errors(): void

Discards the errors that stream_last_errors() would return.

As stored errors are kept until another operation stores errors, clearing them before an operation makes it possible to tell afterwards whether that operation stored any.

参数

此函数没有参数。

返回值

没有返回值。

示例

示例 #1 stream_clear_errors() example

<?php
$context = stream_context_create([
    'stream' => [
        'error_mode' => StreamErrorMode::Silent,
    ],
]);

fopen('/nonexistent/file.txt', 'r', false, $context);
var_dump(count(stream_last_errors()));

stream_clear_errors();
var_dump(count(stream_last_errors()));

以上示例会输出:

int(1)
int(0)

参见

用户贡献的备注

此页面尚无用户贡献的备注。
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top