Loading...

Knowledge Base

What are Error Logs?

An error log is a list of all the errors that a system has run into. It also has diagnostic messages, like errors, warnings, and notes, that happen when the server starts up, shuts down, or is running. Accessing the error log may require special administrative permissions. This is a security measure meant to keep people who shouldn't be able to see error records from doing so.

Checking the error logs can help webmasters find out about problems that people are having. People don't always report errors, so if a webmaster has a broken link, a form that can't be submitted, or something similar, it may show up in the log before anyone tells them about the problem.

Here are the common types of errors that you may encounter in error logs:

Parse error or Syntax error:

This is a type of mistake that the programmer makes in the program's source code. The compiler finds the mistake in the syntax. After the syntax error has been fixed, the compiler will compile the code and run it. Parse errors can be caused by things like missing or extra parentheses, unclosed braces, and missing semicolons, among other things.

Example:
<?php
$x = "techy";
y = "web server";
echo $x;
echo $y;
?>

Error:


PHP Parse error:  syntax error, unexpected '=' 
in /home/18cb2875ac563160a6120819bab084c8.php on line 3
 

Explanation: In the above code, line 3 is missing a $ sign, so an error message is shown.

Fatal Error:

This is a type of error that happens when the PHP compiler understands the PHP code but sees an undefined function. This means that function is called, but the function is not defined.

Example:
<?php
function add($x, $y)
{
    $sum = $x + $y;
    echo "sum = " . $sum;
}
$x = 0;
$y = 20;
add($x, $y);  
diff($x, $y);
?>

Error:


PHP Fatal error:  Uncaught Error:  Call to undefined function diff()  in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12

Stack trace: #0 {main} thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
 

Explanation: In line 12, the function is called, but its definition is not shown. So it gives an error.

Warning Errors:

A missing file is the main cause of warning errors. This means that the missing file is called by the PHP function.

Example:
<?php 
$x = "techyforweb";
include ("gfg.php");
echo $x . "web server host";
?>

Error:


PHP Warning:  include(gfg.php): failed to  open stream: No such file or directory in  /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5

PHP Warning:  include(): Failed opening 'gfg.php'  for inclusion (include_path='.:/usr/share/php') in  /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
 

Explanation: This program tries to open a file called gfg.php that does not exist. So it makes a mistake.

Notice Error:

It's like a warning error. It means that the program has something wrong with it, but it still lets scripts run.

Example:
<?php 
$x = "techyforweb";
echo $x;
echo $web;
?>

Error:


PHP Notice:  Undefined variable: web in  /home/84c47fe936e1068b69fb834508d59689.php on line 5
 

Explanation: This application uses the undeclared variable $web, which causes an error.

Below are the common PHP error constants and what they mean:
  • E ERROR​ is a fatal error that ends the script.
  • E WARNING: A warning that happens during script execution but doesn't end the script.
  • E PARSE: Parse error at compile time.
  • E NOTICE: Run time notice caused due to error in code.
  • E CORE ERROR: Fatal errors that happen when PHP starts up for the first time (installation).
  • E CORE WARNING: Warnings that happen when PHP starts up for the first time. Fatal compile-time errors mean there is a problem with the script.
  • E USER ERROR: User-generated error message.
  • E USER WARNING: A warning message made by the user.
  • E USER NOTICE: A message made by the user.
  • E STRICT: Notices at run time.
  • E RECOVERABLE ERROR: A dangerous error that can be caught and fixed.
  • E DEPRECATED: Run-time notices.

Related Articles:

Using CGI
Website Errors: 403
500 Internal Server Error

 

Loading...