What does the '@' prefix do in PHP?


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.

Updated on: 09-Apr-2020

521 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements