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 = '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; } */ ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Usae
function name:  (null)
number of ops:  57
compiled vars:  !0 = $apiKey, !1 = $destination, !2 = $hotel, !3 = $adults, !4 = $url, !5 = $xml, !6 = $params, !7 = $context, !8 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_W                      global              $9      '_POST'
          1        ASSIGN_DIM                                               $9, 'datepicker1'
          2        OP_DATA                                                  '2013-06-12'
    6     3        FETCH_W                      global              $11     '_POST'
          4        ASSIGN_DIM                                               $11, 'datepicker2'
          5        OP_DATA                                                  '2013-06-16'
    8     6        ASSIGN                                                   !0, '2hkhej72gxyas3ky6hhjtsga'
   10     7        ASSIGN                                                   !1, !2
   11     8        ASSIGN                                                   !3, '2'
   16     9        ASSIGN                                                   !4, 'https%3A%2F%2Fapi.eancdn.com%2Fean-services%2Frs%2Fhotel%2Fv3%2Flist'
   18    10        NEW                                              $17     'SimpleXMLElement'
         11        SEND_VAL_EX                                              '%3CHotelListRequest%2F%3E'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !5, $17
   19    14        ASSIGN_OBJ                                               !5, 'destinationString'
         15        OP_DATA                                                  !1
   20    16        FETCH_R                      global              ~22     '_POST'
         17        FETCH_DIM_R                                      ~23     ~22, 'datepicker1'
         18        ASSIGN_OBJ                                               !5, 'arrivalDate'
         19        OP_DATA                                                  ~23
   21    20        FETCH_R                      global              ~25     '_POST'
         21        FETCH_DIM_R                                      ~26     ~25, 'datepicker2'
         22        ASSIGN_OBJ                                               !5, 'departureDate'
         23        OP_DATA                                                  ~26
   22    24        FETCH_OBJ_W                                      $27     !5, 'RoomGroup'
         25        FETCH_OBJ_W                                      $28     $27, 'Room'
         26        ASSIGN_OBJ                                               $28, 'numberOfAdults'
         27        OP_DATA                                                  !3
   28    28        INIT_ARRAY                                       ~30     55505, 'cid'
   29    29        ADD_ARRAY_ELEMENT                                ~30     99, 'minorRev'
   30    30        ADD_ARRAY_ELEMENT                                ~30     !0, 'apiKey'
   31    31        ADD_ARRAY_ELEMENT                                ~30     'pt_BR', 'locale'
   32    32        ADD_ARRAY_ELEMENT                                ~30     'BRL', 'currencyCode'
   33    33        INIT_METHOD_CALL                                         !5, 'asXML'
         34        DO_FCALL                                      0  $31     
         35        ADD_ARRAY_ELEMENT                                ~30     $31, 'xml'
   27    36        ASSIGN                                                   !6, ~30
   39    37        INIT_FCALL                                               'stream_context_create'
   40    38        INIT_ARRAY                                       ~33     'POST', 'method'
         39        ADD_ARRAY_ELEMENT                                ~33     <array>, 'header'
   45    40        INIT_FCALL                                               'http_build_query'
         41        SEND_VAR                                                 !6
         42        DO_ICALL                                         $34     
         43        ADD_ARRAY_ELEMENT                                ~33     $34, 'content'
         44        INIT_ARRAY                                       ~35     ~33, 'http'
         45        SEND_VAL                                                 ~35
         46        DO_ICALL                                         $36     
   39    47        ASSIGN                                                   !7, $36
   47    48        INIT_FCALL                                               'libxml_set_streams_context'
         49        SEND_VAR                                                 !7
         50        DO_ICALL                                                 
   63    51        INIT_FCALL                                               'simplexml_load_file'
         52        SEND_VAR                                                 !4
         53        SEND_VAL                                                 'MySimpleXMLElement'
         54        DO_ICALL                                         $39     
         55        ASSIGN                                                   !8, $39
   87    56      > RETURN                                                   1

Class MySimpleXMLElement:
Function addprocessinginstruction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Usae
function name:  addProcessingInstruction
number of ops:  20
compiled vars:  !0 = $target, !1 = $data, !2 = $node, !3 = $pi, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   52     2        INIT_FCALL                                               'dom_import_simplexml'
          3        FETCH_THIS                                       ~5      
          4        SEND_VAL                                                 ~5
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   53     7        FETCH_OBJ_R                                      ~8      !2, 'ownerDocument'
          8        INIT_METHOD_CALL                                         ~8, 'createProcessingInstruction'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !3, $9
   54    13        INIT_METHOD_CALL                                         !2, 'appendChild'
         14        SEND_VAR_EX                                              !3
         15        DO_FCALL                                      0  $11     
         16        ASSIGN                                                   !4, $11
   55    17        FETCH_THIS                                       ~13     
         18      > RETURN                                                   ~13
   56    19*     > RETURN                                                   null

End of function addprocessinginstruction

End of class MySimpleXMLElement.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
197.82 ms | 1400 KiB | 23 Q