What is the lowest level error type in PHP

青灯夜游
Release: 2023-03-14 17:32:01
Original
2211 people have browsed it

The lowest level error type in PHP is "deprecated", which means "not recommended, not recommended". This kind of error is generally caused by the use of deprecated or outdated functions or syntax; although it does not affect the normal flow of PHP, it is generally recommended to correct it.

What is the lowest level error type in PHP

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Preface: PHP errors will cause the script to not run normal situation.

There are many kinds of PHP errors, including warning, notice, deprecated, fetal error, etc. Among them, notice is not called a notification, but a notification-level error, and warning is not called a warning, but a warning-level error.

Errors are roughly divided into the following types.

  • deprecated is the lowest level error, which means "not recommended, not recommended". For example, the ereg series of regular matching functions used in PHP5 will report such errors. This error is usually caused by using deprecated or outdated functions or syntax. Although it does not affect the normal flow of PHP, it is generally recommended to correct it.

  • Followed by notice. This kind of error is usually caused by improper grammar. If a variable is used but is not defined, this error will be reported. The most common thing is that when the array index is a character without quotes, PHP treats it as a constant, searches the constant table first, and then treats it as a variable if it is not found. Although PHP is a scripting language and the syntax requirements are not strict, it is still recommended to initialize variables. This error does not affect the normal flow of PHP.

  • warning is a relatively high-level error. This error will be reported when there is a very inappropriate situation in the syntax, such as function parameter mismatch. Errors of this level will result in unexpected results and require code modifications.

  • The higher level error is fetal error. This is a fatal error, which directly causes the PHP process to terminate and the following code will no longer be executed. This kind of problem must be corrected

  • High-level errors are syntax parsing errorsprase error. The errors mentioned above are all errors during the running of the PHP code, while syntax parsing errors are errors during the syntax check phase, which will cause the PHP code to fail the syntax check.

Here are just a few of the most common ones. The PHP manual has a total of 16 levels of errors.

	$date = date('Y-m-d');;
	if(ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})",$date,$regs)){
		echo $regs[1]."-".$regs[2]."-".$regs[3];
	}else{
		echo "没有匹配到";
	}
	//Deprecated(在php5版本),Fatal error(在php7版本)
 
	if($i > 2020){
		echo '$i没有初始化!!!',PHP_EOL;
	}
	//Notice
 
	$arr = array('arr'=>1,2,3);
	echo $arr[arr];
	//Warning
 
	$res = array_sum($arr,1);
	//Warning
 
	echo fun();
	//Fatal error
 
	echo "最高级别错误';
	//Parse error
Copy after login

The above code demonstrates several common error levels in PHP. If the output is not complete, you can check the php.ini configuration file to see if the

error_reporting=E_ALL | E_STRICT
display_errors=On
Copy after login

is set as follows. #error_reporting specifies the error level, and display_errors goes without saying.

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of What is the lowest level error type in PHP. 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