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(get_class($xml)); 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/PFf5H
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 = 48
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 = 31, Position 2 = 36
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 47
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 47
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 36
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
Branch analysis from position: 36
Branch analysis from position: 48
filename:       /in/PFf5H
function name:  appendXML
number of ops:  49
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      
    7     1      > JMPZ                                                     !0, ->48
    8     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
    9     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
   11    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        GET_CLASS                                        ~16     !1
         26        SEND_VAL                                                 ~16
         27        DO_ICALL                                                 
   16    28        INIT_METHOD_CALL                                         !0, 'children'
         29        DO_FCALL                                      0  $18     
         30      > FE_RESET_R                                       $19     $18, ->36
         31    > > FE_FETCH_R                                               $19, !2, ->36
   17    32    >   INIT_METHOD_CALL                                         !1, 'appendXML'
         33        SEND_VAR_EX                                              !2
         34        DO_FCALL                                      0          
   16    35      > JMP                                                      ->31
         36    >   FE_FREE                                                  $19
   20    37        INIT_METHOD_CALL                                         !0, 'attributes'
         38        DO_FCALL                                      0  $21     
         39      > FE_RESET_R                                       $22     $21, ->47
         40    > > FE_FETCH_R                                       ~23     $22, !3, ->47
         41    >   ASSIGN                                                   !4, ~23
   21    42        INIT_METHOD_CALL                                         !1, 'addAttribute'
         43        SEND_VAR_EX                                              !4
         44        SEND_VAR_EX                                              !3
         45        DO_FCALL                                      0          
   20    46      > JMP                                                      ->40
         47    >   FE_FREE                                                  $22
   24    48    > > RETURN                                                   null

End of function appendxml

End of class MySimpleXMLElement.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.02 ms | 1404 KiB | 17 Q