@
to suppress errors PHP-W1078 9 $params['http']['header'] = $optional_headers;
10 }
11 $ctx = stream_context_create($params);
12 $fp = @fopen($url, 'rb', false, $ctx);13 if (!$fp) {
14 throw new Exception("Problem with $url, $php_errormsg");
15 }
13 if (!$fp) {
14 throw new Exception("Problem with $url, $php_errormsg");
15 }
16 $response = @stream_get_contents($fp);17 if ($response === false) {
18 throw new Exception("Problem reading data from $url, $php_errormsg");
19 }
Suppressing errors using an error control operator(@
) is discouraged. Instead of ignoring the raised error, it should be fixed accordingly.
$user = ['name' => 'John', 'age' => 23];
echo @$user['city'];
$user = ['name' => 'John', 'age' => 23];
if (isset($user['city'])) {
echo $user['city'];
}