Code:
<?php
function getDebugData() {
global $_POST, $_GET;
// Make sure we get our share of debug output...
error_reporting(E_ALL);
ini_set('display_errors','Off');
ini_set('error_log','debug_php_msgs.txt');
// Grab and export $_POST
$_debugLogPost = "debug_post.xml";
$_dbgPost = fopen($_debugLogPost, 'w') or die("can't open POST debug log");
fwrite($_dbgPost, print_r_xml($_POST));
fclose($_dbgPost);
// Grab and export $_GET
$_debugLogGet = "debug_get.xml";
$_dbgGet = fopen($_debugLogGet, 'w') or die("can't open GET debug log");
fwrite($_dbgGet, print_r_xml($_GET));
fclose($_dbgGet);
}
/* print the contents of a url */
function print_r_xml($arr,$wrapper = 'data',$cycle = 1)
{
//useful vars
$new_line = "\n";
//start building content
if($cycle == 1) { $output = '<?xml version="1.0" encoding="UTF-8" ?>'.$new_line; }
$output .= tabify($cycle - 1).'<'.$wrapper.'>'.$new_line;
foreach($arr as $key => $val)
{
if(!is_array($val))
{
$output .= tabify($cycle).'<'.htmlspecialchars($key).'>'.$val.'</'.htmlspecialchars($key).'>'.$new_line;
}
else
{
$output .= print_r_xml($val,$key,$cycle + 1).$new_line;
}
}
$output .= tabify($cycle - 1).'</'.$wrapper.'>';
//return the value
return $output;
}
/* tabify */
function tabify($num_tabs)
{
$return = "";
for($x = 1; $x <= $num_tabs; $x++) { $return .= "\t"; }
return $return;
}
?>