Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • ERRORS IN PHP

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 106
    Comment on it

    An error is defined as the unexpected state of the program. An error message is then displayed to the browser.

    There are four types of error in PHP-

    • Parse Error
    • Fatal Error
    • Warning Error
    • Notice Error

    1.Parse Errors- Parse error is also known as syntax error. If there is any mistake in the syntax the parse error will be shown  and it stops the execution of the program.

    common reasons of parse error:

    • Unclosed quotes
    • Unclosed braces
    • Missing semicolon
    • Missing or extra parentheses
    <?php
    echo "apple";
    echo "mango"
    echo "orange";
    ?>

    In the above e.g it will show the parse error because semicolon is missing in the second line.

     

    2.Fatal Error-  A fatal error comes when we want to acquire an undefined function which is not declared in the program. It also stops the execution of the program.

     

    <?php
    function fun1()
    {
    echo "Neha";
    }
    fun2();
    echo "Shilpi";
    ?>

    In the above example the browser will show the fatal error because we have declared the function1 but we are calling the function2.

     

    3.Warning error- Warning error occurs when we use the wrong number of parameters to the function or missing file. It does not stops the execution of the program.

     

    <?php 
    echo "Warning Error!!";
    include ("index.php");
    ?>

    In the above example we are using the file index.php but it does not exist in the directory, so it will display the warning error.

     

    4.Notice Error- Notice error is displayed when we use access the undefined variable. It also does not stops the execution of the program.

     

    <?php
    $a="Neha";
    echo "Notice Error !!";
    echo $b;
    ?>

     

    In the above example we defined a variable $a but we are calling the variable $b, this will show a Notice error.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: