What is the use of @ in php ?

Last Updated by Pooja Chikara 20-Mar-20

0 151


The @ symbol is works as error control operator in PHP. It prevents to display error messages like notice, warning, fatal, etc generated by the particular PHP expression.

Remark: By using @ symbol we can avoid the use of isset() function to avoid variable undefined errors.

Example:

Without using @ symbol

<?php 
$var1="codingtag";
echo $var1;
echo $var2; // it will produce error because var2 is not defined.
?

Output:

What is the use of @ in php ?


After using @ symbol

<?php 
$var1="codingtag";
echo $var1;
echo @$var2; // it will not produce any error just because of @ symbol
?> 

Output:

What is the use of @ in php ?


Share:


Leave a Reply


Comments
    Waiting for your comments