Im working with a foreign API and im trying to get a fix on what all its sending to my file with the GET method.
How can i output something like print_r($_GET) to a file so i can read what all its sending?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Writing to a file:
You could use
file_put_contents()to create the file with your output. This function will accept a string, or an array, which releases you of the burden to convert your array into a writable-format.As stated in the comments, this option isn’t ideal for multidimensional arrays. However, the next solution is.
Maintaining format:
If you’d like to maintain the
print_r()formatting, simply set the second parameter totrueto return the value into a variable rather than outputting it immediately: