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)