Skip to main content

How do you enable error reporting in PHP?

 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.

Comments

Popular Posts

How to find out Max Salary from each department

You can find maximum salary for each department by grouping all records by DeptId and then using MAX() function to calculate maximum salary in each group or each department. SQL Query: SELECT DeptID, MAX(Salary) FROM Employee  GROUP BY DeptID. This questions become more interesting if Interviewer will ask you to print department name instead of department id, in that case you need to join Employee table with Department using foreign key DeptID, make sure you do LEFT or RIGHT OUTER JOIN to include departments without any employee as well.  Here is the query