3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySimpleXMLElement extends SimpleXMLElement { public function appendXML($append) { if ($append) { if (strlen(trim((string)$append)) == 0) { $xml = $this->addChild($append->getName()); } else { $xml = $this->addChild($append->getName(), (string)$append); } foreach ($append->children() as $child) { $xml->appendXML($child); } foreach ($append->attributes() as $n => $v) { $xml->addAttribute($n, $v); } } } } $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/8kEfd
function name:  (null)
number of ops:  28
compiled vars:  !0 = $currentPayment, !1 = $paymentProfile
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $2      'SimpleXMLElement'
          1        SEND_VAL_EX                                              '%3Cpayment%3E%3C%2Fpayment%3E'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   27     4        INIT_METHOD_CALL                                         !0, 'addChild'
          5        SEND_VAL_EX                                              'creditCard'
          6        DO_FCALL                                      0          
   28     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          
   29    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          
   31    17        NEW                                              $10     'MySimpleXMLElement'
         18        SEND_VAL_EX                                              '%3CpaymentProfile%3E%3C%2FpaymentProfile%3E'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !1, $10
   33    21        INIT_METHOD_CALL                                         !1, 'appendXML'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0          
   35    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 = 44
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 43
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 32
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
Branch analysis from position: 32
Branch analysis from position: 44
filename:       /in/8kEfd
function name:  appendXML
number of ops:  45
compiled vars:  !0 = $append, !1 = $xml, !2 = $child, !3 = $v, !4 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1      > JMPZ                                                     !0, ->44
    9     2    >   INIT_FCALL                                               'trim'
          3        CAST                                          6  ~5      !0
          4        SEND_VAL                                                 ~5
          5        DO_ICALL                                         $6      
          6        STRLEN                                           ~7      $6
          7        IS_EQUAL                                                 ~7, 0
          8      > JMPZ                                                     ~8, ->16
   10     9    >   INIT_METHOD_CALL                                         'addChild'
         10        INIT_METHOD_CALL                                         !0, 'getName'
         11        DO_FCALL                                      0  $9      
         12        SEND_VAR_NO_REF_EX                                       $9
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !1, $10
         15      > JMP                                                      ->24
   12    16    >   INIT_METHOD_CALL                                         'addChild'
         17        INIT_METHOD_CALL                                         !0, 'getName'
         18        DO_FCALL                                      0  $12     
         19        SEND_VAR_NO_REF_EX                                       $12
         20        CAST                                          6  ~13     !0
         21        SEND_VAL_EX                                              ~13
         22        DO_FCALL                                      0  $14     
         23        ASSIGN                                                   !1, $14
   15    24    >   INIT_METHOD_CALL                                         !0, 'children'
         25        DO_FCALL                                      0  $16     
         26      > FE_RESET_R                                       $17     $16, ->32
         27    > > FE_FETCH_R                                               $17, !2, ->32
   16    28    >   INIT_METHOD_CALL                                         !1, 'appendXML'
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0          
   15    31      > JMP                                                      ->27
         32    >   FE_FREE                                                  $17
   19    33        INIT_METHOD_CALL                                         !0, 'attributes'
         34        DO_FCALL                                      0  $19     
         35      > FE_RESET_R                                       $20     $19, ->43
         36    > > FE_FETCH_R                                       ~21     $20, !3, ->43
         37    >   ASSIGN                                                   !4, ~21
   20    38        INIT_METHOD_CALL                                         !1, 'addAttribute'
         39        SEND_VAR_EX                                              !4
         40        SEND_VAR_EX                                              !3
         41        DO_FCALL                                      0          
   19    42      > JMP                                                      ->36
         43    >   FE_FREE                                                  $20
   23    44    > > RETURN                                                   null

End of function appendxml

End of class MySimpleXMLElement.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
307.05 ms | 1404 KiB | 16 Q