Upcoming Critical PHP Security Release

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)

Смотрите также

+Добавить

Примечания пользователей

Пользователи ещё не добавляли примечания для страницы
To Top