Avatar ·

What is the @ symbol (dog) for in PHP and how does error suppression work?

Hello everyone! I just started learning PHP and often see a strange @ symbol before functions in other people's code. For example:\n\n```php\n$file = @fopen('config.php', 'r');\n$data = @file_get_contents('http://api.example.com');\n@$result = someFunction();\n```\n\nI understand that it's somehow related to errors, but I don't fully understand it. When I write code without @, accessing a non-existent file or having network issues causes warnings and fatal errors. With @, the errors disappear. But this can't be the right solution, can it?\n\nI have several questions:\n1. How exactly does the @ operator work? Does it suppress all errors or only certain types?\n2. Why do many experienced developers criticize @ and advise against using it?\n3. Are there proper alternatives to handle errors instead?