Home  >  Article  >  How to display error message in phpcms

How to display error message in phpcms

尊渡假赌尊渡假赌尊渡假赌
尊渡假赌尊渡假赌尊渡假赌Original
2023-06-13 14:41:181673browse

How to display error messages in phpcms: 1. Create a PHP sample file; 2. Use "error_reporting(E_ALL)" to display all errors; 3. Set "display_errors" to 1 to output error messages to the browser Just put it in the container.

How to display error message in phpcms

The operating system of this tutorial: Windows 10 system, phpcms v9 version, Dell G3 computer.

To display error information in phpcms, you can use PHP's built-in `error_reporting()` and `ini_set()` functions.

The following is a sample code that displays all error messages:

1. Set the error reporting level

<?php
// 显示所有错误
error_reporting(E_ALL);
// 除了提示级别之外的所有错误
error_reporting(E_ALL & ~E_NOTICE);
// 关闭所有错误报告
error_reporting(0);
?>

These options will tell PHP to display different levels of errors. For example, if you set error_reporting() to E_ALL, PHP will display all errors, including warnings, fatal errors, etc.

2. Modify the INI settings at runtime

<?php
// 显示所有错误
ini_set(&#39;display_errors&#39;, 1);
// 隐藏所有错误
ini_set(&#39;display_errors&#39;, 0);
?>

By calling the ini_set() function and setting the first parameter to display_errors, the second parameter is the specific value of the setting ( 0=hide, 1=show).

Combining these two features, you can implement the following in your code:

<?php
// 显示所有错误
error_reporting(E_ALL);
ini_set(&#39;display_errors&#39;, 1);
?>
<!DOCTYPE html>
<html>
<head>
<title>Error Reporting Example</title>
</head>
<body>
<?php
// Your PHP code here
?>
</body>
</html>

In this example, PHP will display all errors and set display_errors to 1 so that An error message is output to the browser.

The above is the detailed content of How to display error message in phpcms. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn