3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Some little $_POST values and $apiKey are already set. */ $_POST['datepicker1'] = '2013-06-12'; $_POST['datepicker2'] = '2013-06-16'; $apiKey = '.....'; $destination = 'napoli'; $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' => 'it_IT', 'currencyCode' => 'EUR', '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); /* * Perform the API request (and here: insert the stylesheet PI) */ $hotel = simplexml_load_file($url, 'MySimpleXMLElement'); $hotel->addProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="css/stile.xsl"'); $hotel->asXML('php://output'); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: simplexml_load_file(): Argument #2 ($class_name) must be a class name derived from SimpleXMLElement or null, MySimpleXMLElement given in /in/p7o7r:53 Stack trace: #0 /in/p7o7r(53): simplexml_load_file('https://api.ean...', 'MySimpleXMLElem...') #1 {main} thrown in /in/p7o7r on line 53
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: simplexml_load_file() expects parameter 2 to be a class name derived from SimpleXMLElement, 'MySimpleXMLElement' given in /in/p7o7r on line 53 Fatal error: Uncaught Error: Call to a member function addProcessingInstruction() on null in /in/p7o7r:54 Stack trace: #0 {main} thrown in /in/p7o7r on line 54
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Warning: simplexml_load_file() expects parameter 2 to be a class name derived from SimpleXMLElement, 'MySimpleXMLElement' given in /in/p7o7r on line 53 Fatal error: Call to a member function addProcessingInstruction() on null in /in/p7o7r on line 54
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Warning: simplexml_load_file() expects parameter 2 to be a class name derived from SimpleXMLElement, 'MySimpleXMLElement' given in /in/p7o7r on line 53 Fatal error: Call to a member function addProcessingInstruction() on a non-object in /in/p7o7r on line 54
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/p7o7r on line 27
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/p7o7r on line 27
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/p7o7r on line 27
Process exited with code 255.

preferences:
213.23 ms | 401 KiB | 355 Q