Home  >  Article  >  Backend Development  >  Introduction to the usage of php at(@) symbol

Introduction to the usage of php at(@) symbol

高洛峰
高洛峰Original
2017-01-06 15:55:461616browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn