PHP allows us to choose whether or not to display errors to users. There are three ways to enable or disable error reporting in PHP:
Method 1: You can turn the display error parameter in the php.ini file on or off. When it’s on, errors are shown; when it’s off, there are no errors shown or reported. To do this, locate the display error parameter in the php.ini file, then set its value to “on.” Restart the web server's various services. The PHP script's errors will now be visible to end users. Set the display error parameter to “off” to stop reporting errors. The off argument indicates that users won't see any errors.
Method 2: Using the mini set() function is the second way to enable or stop error reporting. The ability to modify the configuration options in the php.ini file is a built-in feature of the PHP programming language. It requires two inputs: the name of the setting you want to change and the value you want to assign.
Method 3: You can also utilize the error reporting() function, a native PHP function, to enable error reporting. This function controls which PHP faults are reported and sets the error reporting directive during runtime. Given that PHP has multiple error levels, this method also aids in setting the various levels for the runtime (duration) of your script. This function accepts parameters for error names like E ERROR, E WARNING, E PARSE, etc., allowing these errors to be reported.