Account
Categories

Error Control Operator (@)


Definition:

If you write a program and don’t want any error to show on the screen, then put @ before the expression that creates the error.

You can use this operator inside a function, outside a function, or anywhere an error can happen.

This symbol hides the error message.

Its simple work is to stop the error from showing on the screen.

Syntax:

@expression

Example:

<?php

$number = 10;
$denominator = 0;
$result = @$number / $denominator;
echo $result;

?>

Output:

0

In the above example, without @, PHP shows a warning (division by zero). After adding @, it hides the warning and shows 0.