2

In looking at various mysql and php code, I've seen the database connection written either with an ampersand or without:

$db = mysqli_connect (db_host, db_user, db_pw, db_name);

vs

$db = @mysqli_connect (db_host, db_user, db_pw, db_name);

Is there are reason some developers use the @ and others do not?

Thank you

4

1 回答 1

7

@错误抑制运算符并隐藏函数输出的警告/错误。使用它通常被认为是不好的做法。

在开发过程中,出现错误消息是有原因的。如果您不想显示错误消息,请在php.ini配置中关闭错误报告并改为记录它们。

于 2013-11-07T18:37:53.223 回答