What are the types of php error prompts?

青灯夜游
Release: 2023-03-15 12:30:02
Original
3575 people have browsed it

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.

What are the types of php error prompts?

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

; 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 &#39;echo&#39; (T_ECHO) in D:\WWW\index.php on line 5
Copy after login

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

What are the types of php error prompts?

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

Error:

What are the types of php error prompts?

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

Error:

What are the types of php error prompts?

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!