PHP @ variables


PHP @ variables

我看到一段来自php网站的代码。在那个代码变量前面写着@symbol,这意味着什么例如:

@hello="嗨";

@是PHP中的错误抑制运算符。

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.

编辑:

典型用途包括:

<?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/

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