What is the use of the @ symbol in PHP?
Last Modified at 2019-06-30 17:21:15
(the at symbol) symbol in PHP is used to suppress the error reporting for the expression prepended with the @
symbol. However; if track_errors
feature is enabled on your server then, any error message generated by the expression will be saved in $php_errormsg
variable and this variable gets overwritten on each error. I would suggest, do not use @
symbol, this is not a good practice. Because this symbol does not disappear the error permanently, it just hide the error from the visitors and also is difficult for developer to identify the error.
Let have look at an example below:
The first statement in above code will throw Notice: Undefined index
error, however, the second statement will not throw any error at all.
Notice: Undefined index: user_id in F:localhosthtdocstesttest.php on line 2
I hope, this tutorial will help you. Please feel free to add your views in the comment box below.