3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySimpleXMLElement extends SimpleXMLElement { public function appendXML($append) { if ($append) { $this_dom = dom_import_simplexml($this); $append_dom = $this_dom->ownerDocument->importNode(dom_import_simplexml($append), true); $this_dom->appendChild($append_dom); } } } $currentPayment = new SimpleXMLElement('<payment></payment>'); $currentPayment->addChild('creditCard'); $currentPayment->creditCard->addChild('cardNumber', 'XXXX0027'); $currentPayment->creditCard->addChild('expirationDate', 'XXXX'); $paymentProfile = new MySimpleXMLElement('<paymentProfile></paymentProfile>'); $paymentProfile->appendXML($currentPayment); echo $paymentProfile->asXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ap1pj
function name:  (null)
number of ops:  28
compiled vars:  !0 = $currentPayment, !1 = $paymentProfile
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $2      'SimpleXMLElement'
          1        SEND_VAL_EX                                              '%3Cpayment%3E%3C%2Fpayment%3E'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   17     4        INIT_METHOD_CALL                                         !0, 'addChild'
          5        SEND_VAL_EX                                              'creditCard'
          6        DO_FCALL                                      0          
   18     7        FETCH_OBJ_R                                      ~6      !0, 'creditCard'
          8        INIT_METHOD_CALL                                         ~6, 'addChild'
          9        SEND_VAL_EX                                              'cardNumber'
         10        SEND_VAL_EX                                              'XXXX0027'
         11        DO_FCALL                                      0          
   19    12        FETCH_OBJ_R                                      ~8      !0, 'creditCard'
         13        INIT_METHOD_CALL                                         ~8, 'addChild'
         14        SEND_VAL_EX                                              'expirationDate'
         15        SEND_VAL_EX                                              'XXXX'
         16        DO_FCALL                                      0          
   21    17        NEW                                              $10     'MySimpleXMLElement'
         18        SEND_VAL_EX                                              '%3CpaymentProfile%3E%3C%2FpaymentProfile%3E'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !1, $10
   23    21        INIT_METHOD_CALL                                         !1, 'appendXML'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0          
   25    24        INIT_METHOD_CALL                                         !1, 'asXML'
         25        DO_FCALL                                      0  $14     
         26        ECHO                                                     $14
         27      > RETURN                                                   1

Class MySimpleXMLElement:
Function appendxml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 19
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/Ap1pj
function name:  appendXML
number of ops:  20
compiled vars:  !0 = $append, !1 = $this_dom, !2 = $append_dom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1      > JMPZ                                                     !0, ->19
    9     2    >   INIT_FCALL                                               'dom_import_simplexml'
          3        FETCH_THIS                                       ~3      
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
   10     7        FETCH_OBJ_R                                      ~6      !1, 'ownerDocument'
          8        INIT_METHOD_CALL                                         ~6, 'importNode'
          9        INIT_FCALL                                               'dom_import_simplexml'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12        SEND_VAR_NO_REF_EX                                       $7
         13        SEND_VAL_EX                                              <true>
         14        DO_FCALL                                      0  $8      
         15        ASSIGN                                                   !2, $8
   11    16        INIT_METHOD_CALL                                         !1, 'appendChild'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0          
   13    19    > > RETURN                                                   null

End of function appendxml

End of class MySimpleXMLElement.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.16 ms | 1392 KiB | 15 Q