Introduction to the usage of php at(@) symbol

高洛峰
Release: 2023-03-04 16:46:02
Original
1622 people have browsed it

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; 
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template