Home > php教程 > php手册 > php编程技术:at(@)符号的简单介绍

php编程技术:at(@)符号的简单介绍

WBOY
Release: 2016-06-13 11:38:36
Original
843 people have browsed it

  帮客之家(www.Bkjia.com)讯 下面介绍一下它的用法.

  1. function db_connect()//连接数据库
  2. {
  3. @$db =mysql_connect('localhost','root','test');
  4. if(!$db)
  5. throw new Exception('连接数据库失败!请重试!');
  6. mysql_select_db('book');
  7. return $db;
  8. }
复制代码

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

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template