Why @ before functions

What does @ add to the function? I saw this in some scenarios

Example:

$connect = @mysql_connect('localhost', 'root', 'password');
 instead of
$connect = mysql_connect('localhost', 'root', 'password');
+3
source share
2 answers

It suppresses any errors that may occur inside the function. The documentation is here .

All of the above, this is not recommended, as this can lead to some vile errors.

+12
source

This is the Error Control Operator , from the php documentation:

PHP supports one error control statement: the at ( @) sign . When added to an expression in PHP, any error messages that may be generated by this expression will be ignored .

set_error_handler(), , ( ) error_reporting(), 0, , @.

track_errors , , , $php_errormsg. , , .

0

Source: https://habr.com/ru/post/1712353/


All Articles