What is the use of @ in php ?
0 2786
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:
After using @ symbol
<?php $var1="codingtag"; echo $var1; echo @$var2; // it will not produce any error just because of @ symbol ?>
Output:
Share:
Comments
Waiting for your comments