Heim  >  Artikel  >  Backend-Entwicklung  >  put your head on my shoulder php at@符号的用法简介

put your head on my shoulder php at@符号的用法简介

WBOY
WBOYOriginal
2016-07-29 08:40:18763Durchsuche

下面介绍一下它的用法.
例如:

复制代码 代码如下:


function db_connect()//连接数据库
{
@$db =mysql_connect('localhost','root','test');
if(!$db)
throw new Exception('连接数据库失败!请重试!');
mysql_select_db('book');
return $db;
}


如果连接数据库不成功的,前面的“@”就能把错误显示给抑制住,也就是不会显示错误,然后再抛出异常,显示自己定义的异常处理,添加这个只是为了让浏览者不看到,不友好的页面,并不能抑制住错误,只能抑制显示错误!@ 用在你觉得以后运行有可能会出现错误的地方 , @后面要来个空格!最好少用,好像增加系统开销.

以上就介绍了put your head on my shoulder php at@符号的用法简介,包括了put your head on my shoulder方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn