Home > Backend Development > PHP Tutorial > About errors encountered in PHP development

About errors encountered in PHP development

藏色散人
Release: 2023-04-08 06:02:01
forward
2142 people have browsed it

In the process of program development and debugging errors, we will always encounter various errors. Some errors will affect the execution of the code, and some will just give a WARNING or NOTICE and will not affect the continuation of the following code. implement.

PHP provides an error control operator @. When it is placed before a PHP expression, any error information that may be generated by the expression is ignored. If you want to control the type of error output, you can use the error_reporting() function to tell the compiler what kind of error should be reported.

int error_reporting ([ int $level ] ): Set what kind of PHP errors should be reported

$level is the error level, return the old [error_reporting] level, or the level parameter is not given Returns the current level.

<?php
// 关闭所有PHP错误报告
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// 报告 E_NOTICE也挺好 (报告未初始化的变量或者捕获变量名的错误拼写)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// 除了 E_NOTICE,报告其他所有错误
error_reporting(E_ALL ^ E_NOTICE);
// 报告所有 PHP 错误 (参见 changelog)
error_reporting(E_ALL);
// 报告所有 PHP 错误
error_reporting(-1);
// 和 error_reporting(E_ALL); 一样
ini_set(&#39;error_reporting&#39;, E_ALL);
?>
Copy after login

The error levels and constants are defined in PHP's predefined constants:

About errors encountered in PHP development

The ones we often encounter in development are E_ERROR, E_WARNING, E_PARSE,E_NOTICE.

For more PHP related knowledge, please visit PHP Tutorial!

The above is the detailed content of About errors encountered in PHP development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template