Home > Common Problem > How to display error message in phpcms

How to display error message in phpcms

尊渡假赌尊渡假赌尊渡假赌
Release: 2023-06-13 14:41:18
Original
1783 people have browsed it

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);
?>
Copy after login

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);
?>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template