pTutorial

New way to learn PHP

PHP 5 Types of error

Types of error

An Error message that the PHP interpreter generate falls into one of the following categories.

  • Syntax Errors
  • Fatal Errors
  • Warnings
  • Notices
  • Logical Errors
  • Environmental Errors
  • Runtime Errors
  • Core Errors
  • Compile Errors
  • User Defined Errors

1. Syntax Errors

Syntax errors are identified when a PHP file is processed, before the PHP interpreter starts executing it. The Syntax Error is easily detected the category of Errors.

  • Missing ( ; ) semicolons
  • Missing () parenthesis
  • Misspelled keywords
  • Missing dollar ( $ ) sign
  • Missing {} curly braces
  • String not closed properly

Missing semicolon

The following code for the unterminated statement

<?php
Echo "Error handling"
Echo "syntax error occur":
?>

Missing () parenthesis

The following code for the Missing () parenthesis

<?php
$a=10
if($a==10
{
Echo "Error handling";
Echo "syntax error occur";
}
?>

Misspelled keywords

The following code for the Misspelled keyword

<?php
echo "misspelled keyword";
echa "syntax error occur";
?>

Missing dollar ( $ ) sign

The following code for the Missing dollar

<?php
num=10;
If ($num == 10)
{
Print "num equal to 10";
}
?>

Missing {} curly braces

The following code for the Missing curly braces

<?php
$num=10;
If ($num == 10)
{
Print "num equal to 10";
echo "error occur";

?>

String not closed properly

The following code for the string unterminated

<?php
echo "error level;
?>

Remember all these points for good Programming practices and readable code.


QUOTES OF THE DAY

Each day provides its own gifts.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER