For full functionality of this site it is necessary to enable JavaScript.
Here are the instructions how to enable JavaScript in your web browser.

Knowledge base

Find the answer to your question

Advanced Search PView

Search terms
Search Type
Sort by

How can I log request and response XMLs in PHP

  • Answer ID 2171
  • Published 03/14/2013 03:26 PM
  • Updated 10/20/2013 06:42 AM
  • Permalink

Suppose that the Request Xml, after being constructed, is stored in the variable - $requestXml, and Response XML, after retreival from eBay, is stored in $responseXml.

PHP provides a library function, error_log to log any strings to local log files, or default PHP error logs.

error_log(var_export($requestXml,true), 3, "/path/to/logFile.log");

// $requestXml - XML to be logged. var_export(with param- true), returns a parsable String representation of the variable, If the variable is not already a string.

// The param 3 - denotes message is appended to the file destination. A newline is not automatically added to the end of the message string.

Similarly, for logging response

error_log(var_export($responseXml,true), 3, "/path/to/request-response.log");

You can also email the logs and log the messages with different flags. Please see Official reference for more information.

How well did this answer your question?

Answers others found helpful

Print Email This Page Delicious Digg Facebook Reddit StumbleUpon Twitter