Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Create a Log File in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 330
    Comment on it

    Log file is very helpful in debugging a large amount of data. We can create a Log file with the piece of code below :-

    $file = fopen ( "testfile.txt" , "a+" );
    fwrite ( $file , serialize ( print_r ( $_POST , true ) ) );
    

    fopen() is php inbuilt function which opens the file and if does not able to find file then it will automatically create a file given as a parameter.

    a+ defines that if you want to write data continues in your file.

    fwrite() is php inbuilt function which writes the content in the file you specified.

    $file defines that file is being created and opened to write.
    serialize() functions serialize the data which comes in variable $output.
    print_r() is a php inbuilt function used to print the array.

    Thanks

 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: