3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* * Some little $_POST values and $apiKey are already set. */ $_POST['datepicker1'] = '2013-06-12'; $_POST['datepicker2'] = '2013-06-16'; $apiKey = '2hkhej72gxyas3ky6hhjtsga'; $destination = $hotel; $adults = '2'; /* * Create the XML for the request with hepl of SimpleXML */ $url = "https://api.eancdn.com/ean-services/rs/hotel/v3/list"; $xml = new SimpleXMLElement('<HotelListRequest/>'); $xml->destinationString = $destination; $xml->arrivalDate = $_POST['datepicker1']; $xml->departureDate = $_POST['datepicker2']; $xml->RoomGroup->Room->numberOfAdults = $adults; /* * Set the parameters for the API request */ $params = [ 'cid' => 55505, 'minorRev' => 99, 'apiKey' => $apiKey, 'locale' => 'pt_BR', 'currencyCode' => 'BRL', 'xml' => $xml->asXML(), ]; /* * Set the stream context for the API request */ $context = stream_context_create(['http' => [ 'method' => 'POST', 'header' => [ 'Accept: application/xml', 'Content-Type: application/x-www-form-urlencoded', ], 'content' => http_build_query($params), ]]); libxml_set_streams_context($context); class MySimpleXMLElement extends SimpleXMLElement { public function addProcessingInstruction($target, $data = NULL) { $node = dom_import_simplexml($this); $pi = $node->ownerDocument->createProcessingInstruction($target, $data); $result = $node->appendChild($pi); return $this; } } /* * Perform the API request (and here: insert the stylesheet PI) */ //$output = '<hotel/>'; $result = simplexml_load_file($url, 'MySimpleXMLElement'); //$hotel->addProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="css/style.xsl"'); //$hotel->asXML('php://output'); //$result = new SimpleXMLElement($hotel); /* function UR_exists($url){ $headers=get_headers($url); return stripos($headers[0],"200 OK")?true:false; } */ /* You can test a URL like this (sample) */ /* $rest = substr((string)$hotel->thumbNailUrl, 0, -5); $rest .= 'y.jpg'; $url = 'http://images.travelnow.com'.$rest; if(UR_exists($url)) { return; } else { continue; } */ ?>
based on 702ZZ
Output for 5.4.15 - 5.4.45, 5.5.33, 5.6.18 - 5.6.19, 7.0.4, 7.0.20, 7.1.5 - 7.2.0
Notice: Undefined variable: hotel in /in/3Usae on line 10 Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: System error in /in/3Usae on line 63 Warning: simplexml_load_file(https://api.eancdn.com/ean-services/rs/hotel/v3/list): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/3Usae on line 63 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://api.eancdn.com/ean-services/rs/hotel/v3/list" in /in/3Usae on line 63
Output for 5.5.24 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 7.0.3, 7.0.5 - 7.0.6, 7.1.0
Notice: Undefined variable: hotel in /in/3Usae on line 10 Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3Usae on line 63 Warning: simplexml_load_file(https://api.eancdn.com/ean-services/rs/hotel/v3/list): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3Usae on line 63 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://api.eancdn.com/ean-services/rs/hotel/v3/list" in /in/3Usae on line 63
Output for 5.4.2 - 5.4.14
Notice: Undefined variable: hotel in /in/3Usae on line 10 Warning: simplexml_load_file(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/3Usae on line 63 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://api.eancdn.com/ean-services/rs/hotel/v3/list" in /in/3Usae on line 63
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/3Usae on line 27
Process exited with code 255.