-3

can you please help i just want to know why we use @in_array function.

$name = array("ravi", "ram", "rani", 87); 


if (in_array("ravi", $name, TRUE)){

}

if (@in_array("ravi", $name, TRUE)){

}
Ravi Chauhan
  • 1,409
  • 13
  • 26
  • 2
    The @("at") symbol just suppresses errors in general – ka_lin Feb 05 '19 at 10:48
  • 3
    Please read the docs before asking http://php.net/manual/en/language.operators.errorcontrol.php – Viktar Pryshchepa Feb 05 '19 at 10:49
  • 1
    There is almost never a reason to use the `@` operator – Philipp Feb 05 '19 at 10:50
  • there is! lazyness :) @Philipp – Bernhard Feb 05 '19 at 10:53
  • @Philipp I've found it very useful when writing functions that have to handle a wide range of input data, including nulls and unassigned values. It's cleaner to check for those issues once inside the function and handle it then, than to wrap many calls to that function with `if` statements. The '@' symbol lets me do that without spamming the error logs. – Ben Hillier Feb 05 '19 at 11:23

2 Answers2

1

The "@" symbol turn off the errors. It is not a good idea to use it.

Mr Tea
  • 141
  • 7
0

PHP Error Control Operators
PHP supports one error control operator:

 the at sign (@

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

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107