php error prompt types are: 1. Parsing error or syntax error. This error will stop the execution of the program and display an error message; 2. Fatal error; 3. Warning error, which means that the syntax of the program does not exist. Error, but during the execution process, some unreasonable aspects of the program are found, thus prompting a warning message, and the program will continue to execute; 4. Pay attention to errors.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php error prompt type
1. Parsing errors or syntax errors
Syntax errors are the most common errors in programming and the easiest to solve. For example: an error message will be displayed if a semicolon is missing. This error stops program execution and displays an error message. We can correct the program based on the error message and re-execute it.
[Example] The following uses simple code to demonstrate common syntax errors and related error messages.
<?php $a = 1; $b = 2; $c = $a + $b echo ; ?>
; is omitted at the end of line 4 in the above code, so running the above code will display the following error message:
Parse error: syntax error, unexpected 'echo' (T_ECHO) in D:\WWW\index.php on line 5
As can be seen from the above example and running results, syntax errors will Prevents the program from continuing downward execution. Only after these errors are resolved can the program execute smoothly.
2. Fatal error:
This is the type of error where the PHP compiler understands the PHP code but it identifies an undeclared function. This means calling a function without a function definition.
For example
<?php function add($x, $y) { $sum = $x + $y; echo "sum = " . $sum; } $x = 0; $y = 20; add($x, $y); diff($x, $y); ?>
Explanation: In line 10, the function diff() is called, but the function diff() does not have a declaration definition, so it gave an error.
3. Warning error:
There is no syntax error in the program, but during the execution process, PHP will find some unreasonable parts of the program and prompt a warning. message, but the program will continue to execute downwards.
Example: When using 0 as the divisor, it will cause the program to run incorrectly and output an error message.
<?php $a = 1; $b = 0; $c = $a / $b; echo "$a / $b = $c"; ?>
Error:
4. Note the error:
It is similar to a warning error, which means The program contains errors, but it allows script execution.
<?php header("content-type:text/html;charset=utf-8"); $x = "PHP中文网"; echo $x; echo $y; ?>
Error:
Description: This program uses an undeclared variable $y, so it gives the error message.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What are the types of php error prompts?. For more information, please follow other related articles on the PHP Chinese website!