2014-08-05 12:53
浏览 23

在PHP中,L值前面的'at'符号是什么意思? [重复]

This question already has an answer here:

Everything I can find refers to the use of the @ symbol as a prefix to an expression, e.g.:

$foo = @bar();

This is not what I'm talking about here. I have a statement which uses the @ symbol as a prefix to an L-value, like:

@$foo = bar();

What does this mean?

(Ideally, please explain the semantics as a de-sugaring of this statement into one that does not use the @ symbol.)


图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • 参考 - 这个符号在PHP中意味着什么? 18 answers \ n

    我能找到的一切都是指使用 @ 符号作为表达式的前缀,例如:

      $ foo = @bar(); 
      <  / pre> 

    这是我在这里谈论的内容。 我有一个声明,它使用 @ 符号作为L值的前缀,如:

      @ $ foo = bar(); \  n   


    (理想情况下,请将语义解释为将此语句解压为一个语句 不使用 @ 符号。)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douyu9433
    douyu9433 2014-08-05 12:55

    @ symbol is used to suppress error messages

    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.

    For example;

    The following code doesn't produce any errors on screen;

    ini_set('error_reporting', E_ALL);
    ini_set('display_errors', 1);
    @$foo = $bar;
    echo $foo;

    However, without the @ it does;

    Notice: Undefined variable: bar in C:\xampp\htdocs\test\test.php on line 6

    点赞 评论