Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create log file in PHP

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 122
    Comment on it

    If you want to debug a large amount of data. You need to create a Log file with the following piece of code.

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

    fopen(): It is inbuilt function which opens the file & if it does not able to find file then it will automatically create a new file with name given as a parameter.

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

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

    $file: It is variable name that assign to the created file.

    serialize() : This functions serialize the data which comes in variable $output.

    print_r(): It is a php inbuilt function used to print the array.

 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: