Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • die() function in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 104
    Comment on it

    die() function is error handling method in PHP which used to handle a error in web application. It's also used to check whether the function is work properly or not.

    <?php
    $file=fopen("myfile.txt","r");
    ?>
    

    If myfile.txt file does not exist, you might get an error like this in your front end:

    Warning: fopen(myfile.txt) [function.fopen]: failed to open stream. No such file or directory

    die() function example:

    <?php
    if(!file_exists("myfile.txt")) {
      die("File not found"); // here die() function remove the warning msg & print file not found..
    } else {
      $file=fopen("myfile.txt","r");
    }
    ?>
    

 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: