Connect with us

Hi, what are you looking for?

Tech BableTech Bable

Blog

What are the four different types of PHP errors?

PHP

Introduction

When an error develops in PHP, it is referred to as a PHP Error. Whether it’s a missing semicolon or the erroneous variable being called, the issue can be very simple or quite complex.

You need to know what kind of problem is happening in a PHP script before you can fix it effectively.

PHP programmers occasionally see this utilized stat method and are unsure of the cause How to fix “The useState set method not reflecting a change immediately”?

The following four sorts of PHP errors:

  1. Fatal Error
  2. Warning Error
  3. Parse Error
  4. Notice Error

Fatal Error

Critical errors are ones that cause your software to become unresponsive and are referred to as fatal errors. The most common cause of errors of this kind is the presence in the script of an undefined function or class.

There are three categories of mistakes that might have catastrophic consequences:

  1. Error fatal at startup (occurring when the system is unable to run the code after installation)
  2. Compile time fatal error (when a programmer tries to use nonexistent data)
  3. Runtime fatal error (happens while the program is running, causing the code to stop working completely)

For example, attempting to run the following script will end in a disastrous failure:

 

<?php

function sub()

{

$sub=6-1;

echo “The sub= “.$sub;

}

div();

?>

 

Warning Error

The script will continue to run even if it encounters a warning error in PHP. It does little more than alert you to the fact that there is a problem, one that is likely to lead to more significant problems in the future.

The following are the most prevalent reasons for warning errors:

  1. Invoking the existence of an external file that is not present in the directory
  2. Incorrect values entered into a function’s parameters

Take, for example:

<?php

echo “Warning error”‘;

include (“external_file.php”);

?>

 

Parse Error

Incorrect use of a symbol or the absence of a symbol in syntax might lead to a parse error. The problem is detected by the compiler, which then stops the script from running.

Errors in parsing can be brought on by:

  • brackets or quotations that aren’t completely closed
  • a lack of or an excessive number of semicolons or parentheses 
  • Misspellings

The following script, for instance, would cause the execution to halt and would raise a parsing error:

 

<?php

cho “Red”;

echo “Blue”;

echo “Green”

?>e

Notice Error

Errors in the notice are considered minor errors. They are comparable to errors that serve as warnings in that the execution of the code is not halted. The majority of the time, the system is unable to determine whether or not it is a true error or simply typical code. Scripts frequently run into problems when they attempt to access variables that have not been defined.

Example:

 

<?php

$a=”Defined error”;

echo “Notice error”;

echo $b;

?>

Final Words

Learning the distinctions between the four distinct sorts of PHP errors might assist you in rapidly locating and resolving issues that have arisen within your script. It is imperative that you pay close attention to the output messages since they frequently reflect on further problems or cautions. 

If you are looking for a defect on your website, knowing the version of PHP that your web server is using is an additional piece of information that can be helpful.

Thanks For Reading
More Read On Tech Bable 

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Laptop

Google Pixelbook 12in is the latest Chromebook invention with advanced features and an elegant appearance. Chromebooks are different from older PCs and laptops. They...

Gadgets

The Alienware Aurora is an excellent midrange gaming laptop, with a side-mounted panel that allows for easy access to all components. The Alienware Aurora 2019...

Laptop

Introduction The Google Pixel Slate M3 is a 2-in-1 detachable laptop that was released in 2018 as part of Google’s Pixel lineup of devices....

Apps

NFTs and stocks are the most well-known types of speculation these days. Either way, both choices will provide funders with many benefits, but they...