What does the '@' prefix do in PHP?

PHPServer Side ProgrammingProgramming

The ‘@’ symbol suppresses errors from getting displayed on the screen.

PHP supports an error control operator, i.e the sign (@). When it is prepended to an expression in PHP, error messages that could get generated when it uses that expression will be ignored.

If the track_errors attribute is enabled, the error message generated by the expression will be saved in the variable named $php_errormsg. This variable will be overwritten each time on every error.

It is always suggested to write code that works relevantly with error states/conditions.

Published on 09-Apr-2020 15:01:35