What does the @ symbol do in PHP?

If you’ve noticed an @ symbol in some PHP code – you’re likely wondering exactly what it does.

The @ symbol in PHP is an “error control operator” – which means it’s used to for error handling.

Using this allows a PHP script to continue running when it experiences an error – and can use further functions to handle the error messages.

For example, if trying to get the contents of a file that doesn’t exist

$file_name = @file_get_contents('this_file_does_not_exist') OR
	print_r( error_get_last() );

Will output the error message, while letting the script continue to run.

For more information on where and how to use this see the official documentation – PHP: Error Control Opperators.