Here's an introduction to its usage.
For example:
Copy code The code is as follows:
function db_connect( )//Connect to the database
{
@$db =mysql_connect('localhost','root','test');
if(!$db)
throw new Exception('Connect to the database Failed! Please try again!');
mysql_select_db('book');
return $db;
}
If the connection to the database is unsuccessful, the preceding "@ "You can suppress the error display, that is, the error will not be displayed, and then an exception will be thrown to display your own defined exception handling. This is added just to prevent viewers from seeing it. Unfriendly pages cannot be suppressed. Error, you can only suppress the error display! @ 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.
http://www.bkjia.com/PHPjc/320296.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320296.htmlTechArticleThe following introduces its usage. For example: Copy the code as follows: function db_connect()//Connect to the database { @ $db =mysql_connect('localhost','root','test'); if(!$db) throw new Except...