Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

Error control (@)

Suppress ordinary diagnostics generated while evaluating an expression.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

@$expression

Suppress ordinary diagnostics generated while evaluating an expression. The expression still executes and its failure result still needs to be handled. A custom error handler may still be called, and thrown exceptions are not swallowed. A suppressed missing-file warning therefore does not turn a failed file read into an empty string.

@$expression
[true,false]

Examples

<?php
$missing = __DIR__ . '/unavailable-note.txt';
$data = @file_get_contents($missing);
echo json_encode([$data === false, $data === '']);

Result

[true,false]

Sources