search
Homephp教程php手册PHP 前加at符合@的作用解析

大家在写php代码的时候,前面总是加上@符号,大家知道什么意思吗?下面小编给大家分享下@符号的作用,需要的朋友可以参考下

大家在做PHP项目时,总是有些代码行前加上@符号,大家都知道是什么意思吗?下面给大家分享下PHP中函数前加at符合@的作用解析

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

复制代码 代码如下:


@$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 = mysqli_conncet("q","w","e","r");

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

这里随便记一下。

以上就是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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)