PHP error handl...LOGIN

PHP error handling prohibits display of errors

In the php.ini configuration file (see Chapter 9.1 Opening php.ini). We can control the error display status of php.

There is a special configuration item in php.ini:

display_errors

This option sets whether to output error messages to the web page, or hidden from the user without being displayed.

The status of this value is on or off, and the value can also be set to 1 or 0.

If the value of display_error is set to 0 or off, the error will not be displayed on the page. If it is set to 1 or on, the error message will be displayed.

Question: What should I do if I don’t have the status permission to modify the server php.ini?

You can use ini_set.

<?php
ini_set('display_errors' , 0 );
?>

The above code is also equivalent to modifying the value of display_errors in php.ini. However, it only takes effect in the current php code.

Question: What should I do if I want to obtain the configuration item status of php.ini?

You can use ini_get (parameter item) to get the value of the parameter.

Demonstration example:

<?php
echo '服务器中display_errors的状态为' . ini_get('display_errors');
?>

Note: After modifying the php.ini file, you need to restart the server.


Next Section
<?php echo '服务器中display_errors的状态为' . ini_get('display_errors'); ?>
submitReset Code
ChapterCourseware