What does @ mean in PHP? [duplicate]

Solution 1:

The @ operator tells PHP to suppress error messages, so that they will not be shown.

For instance, using:

$result = mysql_query("this is an invalid query");

would result in a warning being shown, telling you that the MySQL query is invalid, while

$result = @mysql_query("this is still an invalid query");

would not.

Note, however, that this is very bad programming practice as it does not make error disappear, it just hides them, and it makes debugging a heck of a lot worse since you can't see what's actually wrong with your code.

Instead of using @, you should disable error_reporting and display_errors just display_errors in php.ini

Solution 2:

The @ sign tells PHP to ignore error messages.

PHP Error Control Operators

Solution 3:

It's an error control operator.

Solution 4:

The @ is a way to tell that you don't want to print error messages. It's a bad practice because you might have an error and never see it because you just "hid" it.

PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.


Resources :

  • @ Operator