3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class tfXmlHelper { private function a2x($array, &$xml_obj) { foreach ($array as $key => $value) { if (is_array($value)) { $key = is_numeric($key) ? "item$key" : $key; $subnode = $xml_obj->addChild("$key"); self::a2x($value, $subnode); } else { $key = is_numeric($key) ? "item$key" : $key; $xml_obj->addChild("$key", "$value"); } } } public static function xml_encode($array) { $xml_obj = new SimpleXMLElement("<root></root>"); self::a2x($array, $xml_obj); return $xml_obj->asXML(); } } class XmlHelper extends tfXmlHelper { } $test_obj = array( 'key' => 'value', 'item' => array( 'stuff', 'more_stuff' ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/17HIf
function name:  (null)
number of ops:  2
compiled vars:  !0 = $test_obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN                                                   !0, <array>
   37     1      > RETURN                                                   1

Class tfXmlHelper:
Function a2x:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 44
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 44
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 35
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/17HIf
function name:  a2x
number of ops:  46
compiled vars:  !0 = $array, !1 = $xml_obj, !2 = $value, !3 = $key, !4 = $subnode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2      > FE_RESET_R                                       $5      !0, ->44
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->44
          4    >   ASSIGN                                                   !3, ~6
    8     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~8, ->27
    9     7    >   INIT_FCALL                                               'is_numeric'
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                         $9      
         10      > JMPZ                                                     $9, ->15
         11    >   NOP                                                      
         12        FAST_CONCAT                                      ~10     'item', !3
         13        QM_ASSIGN                                        ~11     ~10
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~11     !3
         16    >   ASSIGN                                                   !3, ~11
   10    17        INIT_METHOD_CALL                                         !1, 'addChild'
         18        CAST                                          6  ~13     !3
         19        SEND_VAL_EX                                              ~13
         20        DO_FCALL                                      0  $14     
         21        ASSIGN                                                   !4, $14
   11    22        INIT_STATIC_METHOD_CALL                                  'a2x'
         23        SEND_VAR                                                 !2
         24        SEND_REF                                                 !4
         25        DO_FCALL                                      0          
         26      > JMP                                                      ->43
   13    27    >   INIT_FCALL                                               'is_numeric'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $17     
         30      > JMPZ                                                     $17, ->35
         31    >   NOP                                                      
         32        FAST_CONCAT                                      ~18     'item', !3
         33        QM_ASSIGN                                        ~19     ~18
         34      > JMP                                                      ->36
         35    >   QM_ASSIGN                                        ~19     !3
         36    >   ASSIGN                                                   !3, ~19
   14    37        INIT_METHOD_CALL                                         !1, 'addChild'
         38        CAST                                          6  ~21     !3
         39        SEND_VAL_EX                                              ~21
         40        CAST                                          6  ~22     !2
         41        SEND_VAL_EX                                              ~22
         42        DO_FCALL                                      0          
    7    43    > > JMP                                                      ->3
         44    >   FE_FREE                                                  $5
   17    45      > RETURN                                                   null

End of function a2x

Function xml_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/17HIf
function name:  xml_encode
number of ops:  13
compiled vars:  !0 = $array, !1 = $xml_obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        NEW                                              $2      'SimpleXMLElement'
          2        SEND_VAL_EX                                              '%3Croot%3E%3C%2Froot%3E'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $2
   22     5        INIT_STATIC_METHOD_CALL                                  'a2x'
          6        SEND_VAR                                                 !0
          7        SEND_REF                                                 !1
          8        DO_FCALL                                      0          
   23     9        INIT_METHOD_CALL                                         !1, 'asXML'
         10        DO_FCALL                                      0  $6      
         11      > RETURN                                                   $6
   24    12*     > RETURN                                                   null

End of function xml_encode

End of class tfXmlHelper.

Class XmlHelper:
Function a2x:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 44
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 44
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 35
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/17HIf
function name:  a2x
number of ops:  46
compiled vars:  !0 = $array, !1 = $xml_obj, !2 = $value, !3 = $key, !4 = $subnode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2      > FE_RESET_R                                       $5      !0, ->44
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->44
          4    >   ASSIGN                                                   !3, ~6
    8     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~8, ->27
    9     7    >   INIT_FCALL                                               'is_numeric'
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                         $9      
         10      > JMPZ                                                     $9, ->15
         11    >   NOP                                                      
         12        FAST_CONCAT                                      ~10     'item', !3
         13        QM_ASSIGN                                        ~11     ~10
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~11     !3
         16    >   ASSIGN                                                   !3, ~11
   10    17        INIT_METHOD_CALL                                         !1, 'addChild'
         18        CAST                                          6  ~13     !3
         19        SEND_VAL_EX                                              ~13
         20        DO_FCALL                                      0  $14     
         21        ASSIGN                                                   !4, $14
   11    22        INIT_STATIC_METHOD_CALL                                  'a2x'
         23        SEND_VAR                                                 !2
         24        SEND_REF                                                 !4
         25        DO_FCALL                                      0          
         26      > JMP                                                      ->43
   13    27    >   INIT_FCALL                                               'is_numeric'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $17     
         30      > JMPZ                                                     $17, ->35
         31    >   NOP                                                      
         32        FAST_CONCAT                                      ~18     'item', !3
         33        QM_ASSIGN                                        ~19     ~18
         34      > JMP                                                      ->36
         35    >   QM_ASSIGN                                        ~19     !3
         36    >   ASSIGN                                                   !3, ~19
   14    37        INIT_METHOD_CALL                                         !1, 'addChild'
         38        CAST                                          6  ~21     !3
         39        SEND_VAL_EX                                              ~21
         40        CAST                                          6  ~22     !2
         41        SEND_VAL_EX                                              ~22
         42        DO_FCALL                                      0          
    7    43    > > JMP                                                      ->3
         44    >   FE_FREE                                                  $5
   17    45      > RETURN                                                   null

End of function a2x

Function xml_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/17HIf
function name:  xml_encode
number of ops:  13
compiled vars:  !0 = $array, !1 = $xml_obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        NEW                                              $2      'SimpleXMLElement'
          2        SEND_VAL_EX                                              '%3Croot%3E%3C%2Froot%3E'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $2
   22     5        INIT_STATIC_METHOD_CALL                                  'a2x'
          6        SEND_VAR                                                 !0
          7        SEND_REF                                                 !1
          8        DO_FCALL                                      0          
   23     9        INIT_METHOD_CALL                                         !1, 'asXML'
         10        DO_FCALL                                      0  $6      
         11      > RETURN                                                   $6
   24    12*     > RETURN                                                   null

End of function xml_encode

End of class XmlHelper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.23 ms | 1408 KiB | 15 Q