首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP @ variables

PHP @ variables
EN

Stack Overflow用户
提问于 2012-03-23 16:19:16
回答 2查看 408关注 0票数 0

我从一个网站上看到了一段代码,是用php写的。在code变量中,前面写着@ symbol,这是什么意思,例如:

@hello = "hi";

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-03-23 16:21:38

@是PHP中的错误抑制操作符。

代码语言:javascript
复制
PHP supports one error control operator: the at sign (@). 
When prepended to an expression in PHP, any error messages that might be 
generated by that expression will be ignored.

编辑:

典型用法包括:

代码语言:javascript
复制
<?php
// Usage of the @ symbol in PHP code

// Typical Example
$var = @some_function();

// Class/Object Example
$var = @new some_class();

// Does NOT Work!
//$var = new @some_class(); // syntax error

// Another example. Very slow
$var = @$some_var;

?>

请参阅以下链接:

http://php.net/manual/en/language.operators.errorcontrol.php

http://michelf.com/weblog/2005/bad-uses-of-the-at-operator/

票数 3
EN

Stack Overflow用户

发布于 2012-03-23 16:23:53

@不能与没有$的变量一起使用。这是语法错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9835933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档