Home  >  Article  >  Backend Development  >  put your head on my shoulder php at@ symbol introduction

put your head on my shoulder php at@ symbol introduction

WBOY
WBOYOriginal
2016-07-29 08:40:18798browse

Here is an introduction to its usage.
For example:

Copy the code The code is as follows:


function db_connect()//Connect to the database
{
@$db =mysql_connect('localhost','root',' test');
if(!$db)
throw new Exception('Failed to connect to the database! Please try again!');
mysql_select_db('book');
return $db;
}


If the database connection fails Successfully, the "@" in front can suppress the error display, that is, the error will not be displayed, and then an exception will be thrown to display the exception handling defined by yourself. This is added just to prevent the viewer from seeing it, which is unfriendly. The page 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 may increase system overhead.

The above introduces the usage of put your head on my shoulder php at@ symbol, including the content of put your head on my shoulder. I hope it will be helpful to friends who are interested in PHP tutorials.

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