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); } var_dump($append); foreach ($append 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/WFb2T
function name:  (null)
number of ops:  28
compiled vars:  !0 = $currentPayment, !1 = $paymentProfile
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $2      'SimpleXMLElement'
          1        SEND_VAL_EX                                              '%3Cpayment%3E%3C%2Fpayment%3E'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   28     4        INIT_METHOD_CALL                                         !0, 'addChild'
          5        SEND_VAL_EX                                              'creditCard'
          6        DO_FCALL                                      0          
   29     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          
   30    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          
   32    17        NEW                                              $10     'MySimpleXMLElement'
         18        SEND_VAL_EX                                              '%3CpaymentProfile%3E%3C%2FpaymentProfile%3E'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !1, $10
   34    21        INIT_METHOD_CALL                                         !1, 'appendXML'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0          
   36    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 = 45
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 = 28, Position 2 = 33
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 44
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 44
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 33
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
Branch analysis from position: 33
Branch analysis from position: 45
filename:       /in/WFb2T
function name:  appendXML
number of ops:  46
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, ->45
    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
   14    24    >   INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                                 
   16    27      > FE_RESET_R                                       $17     !0, ->33
         28    > > FE_FETCH_R                                               $17, !2, ->33
   17    29    >   INIT_METHOD_CALL                                         !1, 'appendXML'
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0          
   16    32      > JMP                                                      ->28
         33    >   FE_FREE                                                  $17
   20    34        INIT_METHOD_CALL                                         !0, 'attributes'
         35        DO_FCALL                                      0  $19     
         36      > FE_RESET_R                                       $20     $19, ->44
         37    > > FE_FETCH_R                                       ~21     $20, !3, ->44
         38    >   ASSIGN                                                   !4, ~21
   21    39        INIT_METHOD_CALL                                         !1, 'addAttribute'
         40        SEND_VAR_EX                                              !4
         41        SEND_VAR_EX                                              !3
         42        DO_FCALL                                      0          
   20    43      > JMP                                                      ->37
         44    >   FE_FREE                                                  $20
   24    45    > > RETURN                                                   null

End of function appendxml

End of class MySimpleXMLElement.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.56 ms | 1404 KiB | 17 Q