2

What does the @ mean below? Is this a situation where $http_url is empty or null and we assign it a variable if so?

@$http_url or $http_url = $scheme .
                              '://' . $_SERVER['HTTP_HOST'] .
                              $port .
                              $_SERVER['REQUEST_URI'];
Mike Flynn
  • 21,905
  • 50
  • 167
  • 308
  • It's sort of a non-idiomatic way of using the existing `$http_url` or setting a default value for it if not set (because PHP would issue a notice for an undefined variable if not set). You will rarely see this kind of expression in PHP - it is much more common in JavaScript or Ruby for example, where the language supports it without a hack to suppress the E_NOTICE. – Michael Berkowski May 19 '15 at 13:43
  • It would be equivalent to something like `$http_url = !isset($http_url) ? $scheme..... : $http_url;` – Michael Berkowski May 19 '15 at 13:45

3 Answers3

2

You are telling php to ignore errors thrown.

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.

taxicala
  • 20,376
  • 7
  • 31
  • 65
1

Note: @ isn't an ampersand, ampersand is &

@ is the stfu operator. It's purpose is to suppress error messages.

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

Ali Gajani
  • 13,720
  • 8
  • 49
  • 83
0

It means that errors wont be displayed on screen, incase any generated, php interpreter ignores it. Useful when writing code directly in view or php file which has less checks or if old framework is used.

Sashant Pardeshi
  • 1,065
  • 7
  • 20