search

php中at(

Jun 06, 2016 pm 07:50 PM
2 millionlinuxphptechnologyCommunityforumEnter

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 对于php的初学者,经常会看到在一个函数名字前面有一个at(@)符号,但是不知道它的作用和用法,去掉后好像对程序没有什么影响,感到很困惑,简单的说@可以忽略错误,有仰制错误的功能为错误控制操作符.下面

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  对于php的初学者,经常会看到在一个函数名字前面有一个at(@)符号,但是不知道它的作用和用法,去掉后好像对程序没有什么影响,感到很困惑,简单的说@可以忽略错误,有仰制错误的功能为错误控制操作符.下面介绍一下它的用法.

  例如:

  function db_connect()//连接数据库

  {

  @$db =mysql_connect('localhost','root','test');

  if(!$db)

  throw new Exception('连接数据库失败!请重试!');

  mysql_select_db('book');

  return $db;

  }

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

php中at(

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools