Home > Backend Development > PHP Tutorial > PHP @ at 记号的作用示例介绍_PHP

PHP @ at 记号的作用示例介绍_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-31 19:29:17
Original
813 people have browsed it

看PHP的代码,总有些行前边有@符号,一直不知道是什么意思。 例如dede5.7 @ni=imagecreatetruecolor(ftoW,$ftoH);

今天用到了,就记一下吧。其实它是错误控制符,即即使出现错误,也无视出现的错误信息,继续执行下边的代码。

@$page=$_GET['page']?intval($_GET['page']):1;

这句是从URL中获取page关键字的值,比如"index.php?page=5",则$page就会取到5。

但是如果有error,比如"index.php"后没有page关键字了,如果去取$_GET['page']不存在就会报错,这时有@就可以忽视这个小错误了。

又比如:

$conn = mysqli_conncet("q","w","e","r");

这样会输入错误信息,关于连接数据库方面的。

如果$conn前面加@的话就可以不让他输出错误信息了。

@$conn = mysqli_conncet("q","w","e","r");

这里随便记一下。

Related labels:
@ at php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template