3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL); function XMLRPC_response($return_value, $server = NULL){ $data["methodResponse"]["params"]["param"]["value"] = $return_value; $return = XML_serialize($data); if(defined('XMLRPC_DEBUG') and XMLRPC_DEBUG){ XMLRPC_debug('XMLRPC_response', "<p>Received the following data to return:</p>\n\n" . XMLRPC_show($return_value, 'print_r', true)); } header("Connection: close"); header("Content-Length: " . strlen($return)); header("Content-Type: text/xml"); header("Date: " . date("r")); if($server){ header("Server: $server"); } if(defined('XMLRPC_DEBUG') and XMLRPC_DEBUG){ XMLRPC_debug('XMLRPC_response', "<p>Sent the following response:</p>\n\n" . XMLRPC_show($return, 'print_r', true)); } echo $return; //file_put_contents('xmlrpc.xml', $return); } function XMLRPC_error($faultCode, $faultString, $server = NULL){ $array["methodResponse"]["fault"]["value"]["struct"]["member"] = array(); $temp = &$array["methodResponse"]["fault"]["value"]["struct"]["member"]; $temp[0]["name"] = "faultCode"; $temp[0]["value"]["int"] = $faultCode; $temp[1]["name"] = "faultString"; $temp[1]["value"]["string"] = $faultString; $return = XML_serialize($array); header("Connection: close"); header("Content-Length: " . strlen($return)); header("Content-Type: text/xml"); header("Date: " . date("r")); if($server){ header("Server: $server"); } if(defined('XMLRPC_DEBUG') and XMLRPC_DEBUG){ XMLRPC_debug('XMLRPC_error', "<p>Sent the following error response:</p>\n\n" . XMLRPC_show($return, 'print_r', true)); } echo $return; } function XMLRPC_convert_timestamp_to_iso8601($timestamp){ #takes a unix timestamp and converts it to iso8601 required by XMLRPC #an example iso8601 datetime is "20010822T03:14:33" return date("Ymd\TH:i:s", $timestamp); } function XMLRPC_convert_iso8601_to_timestamp($iso8601){ return strtotime($iso8601); } function count_numeric_items(&$array){ return is_array($array) ? count(array_filter(array_keys($array), 'is_numeric')) : 0; } function XMLRPC_debug($function_name, $debug_message){ $GLOBALS['XMLRPC_DEBUG_INFO'][] = array($function_name, $debug_message); } function XMLRPC_debug_print(){ if($GLOBALS['XMLRPC_DEBUG_INFO']){ echo "<table border=\"1\" width=\"100%\">\n"; foreach($GLOBALS['XMLRPC_DEBUG_INFO'] as $debug){ echo "<tr><th style=\"vertical-align: top\">$debug[0]</th><td>$debug[1]</td></tr>\n"; } echo "</table>\n"; unset($GLOBALS['XMLRPC_DEBUG_INFO']); }else{ echo "<p>No debugging information available yet.</p>"; } } function XMLRPC_show($data, $func = "print_r", $return_str = false){ ob_start(); $func($data); $output = ob_get_contents(); ob_end_clean(); if($return_str){ return "<pre>" . htmlspecialchars($output) . "</pre>\n"; }else{ echo "<pre>", htmlspecialchars($output), "</pre>\n"; } }
based on n8qYj
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0