Home >Backend Development >PHP Tutorial >Introduction to the usage of php at(@) symbol
The following introduces its usage.
For example:
function db_connect()//连接数据库 { @$db =mysql_connect('localhost','root','test'); if(!$db) throw new Exception('连接数据库失败!请重试!'); mysql_select_db('book'); return $db; }
If the connection to the database is unsuccessful, the preceding "@" can suppress the error display, that is, it will not Display errors, then throw exceptions, and display your own defined exception handling. This is added just to prevent viewers from seeing the unfriendly page. It cannot suppress errors, it can only suppress display errors! @ is used where you think there may be errors in future operations. There should be a space after @! It is best to use less, as it seems to increase system overhead.
For more introduction to the usage of the php at(@) symbol, please pay attention to the PHP Chinese website for related articles!