Home > Backend Development > PHP Tutorial > Introduction to the usage of php at(@) symbol_PHP tutorial

Introduction to the usage of php at(@) symbol_PHP tutorial

WBOY
Release: 2016-07-21 15:45:35
Original
882 people have browsed it

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.

www.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...
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