0

php echo starts with '@' sign for show a variable,

Example:

<?php echo @$user_profile['id'];?>

why @ sign used here?

Cœur
  • 37,241
  • 25
  • 195
  • 267
kumar
  • 159
  • 8
  • Possible duplicate of [why use @before variable. can someone pls explain](https://stackoverflow.com/questions/4151418/why-use-before-variable-can-someone-pls-explain) – hungrykoala Jun 20 '18 at 04:59
  • so it means hide the error – kumar Jun 20 '18 at 05:00
  • Possible duplicate: https://stackoverflow.com/questions/1032161/what-is-the-use-of-the-symbol-in-php – Mawia HL Jun 20 '18 at 05:01
  • @kumar Not an error, a notice, which may/may not be an error. If the DOM or where ever this is executed is not looking for the output of `$user_profile['id']` it will be fine. – user3783243 Jun 20 '18 at 05:02
  • 1
    Possible duplicate of [What is the use of the @ symbol in PHP?](https://stackoverflow.com/questions/1032161/what-is-the-use-of-the-symbol-in-php) – Pradeep Jun 20 '18 at 05:04
  • ok thank you for update – kumar Jun 20 '18 at 05:05
  • Possible duplicate of [Reference — What does this symbol mean in PHP?](https://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – I am the Most Stupid Person Jun 20 '18 at 06:05

2 Answers2

5

That is just suppressing notices when the variable is not available.

See http://php.net/manual/en/language.operators.errorcontrol.php for more info.

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.

user3783243
  • 5,368
  • 5
  • 22
  • 41
-1

PHP supports one error control operator: the at sign (@). When used with an expression in PHP, any error messages that might be generated by that expression will be ignored.

More info here

charan kumar
  • 2,119
  • 2
  • 20
  • 26