3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); function & XML_serialize(&$data, $level = 0, $prior_key = NULL){ #assumes a hash, keys are the variable names $xml_serialized_string = ""; while(list($key, $value) = each($data)){ $inline = false; $numeric_array = false; $attributes = ""; #echo "My current key is '$key', called with prior key '$prior_key'<br>"; if(!strstr($key, " attr")){ #if it's not an attribute if(array_key_exists("$key attr", $data)){ while(list($attr_name, $attr_value) = each($data["$key attr"])){ #echo "Found attribute $attribute_name with value $attribute_value<br>"; $attr_value = &htmlspecialchars($attr_value, ENT_QUOTES); $attributes .= " $attr_name=\"$attr_value\""; } } if(is_numeric($key)){ #echo "My current key ($key) is numeric. My parent key is '$prior_key'<br>"; $key = $prior_key; }else{ #you can't have numeric keys at two levels in a row, so this is ok #echo "Checking to see if a numeric key exists in data."; if(is_array($value) and array_key_exists(0, $value)){ # echo " It does! Calling myself as a result of a numeric array.<br>"; $numeric_array = true; $xml_serialized_string .= XML_serialize($value, $level, $key); } #echo "<br>"; } if(!$numeric_array){ $xml_serialized_string .= str_repeat("\t", $level) . "<$key$attributes>"; if(is_array($value)){ $xml_serialized_string .= "\r\n" . XML_serialize($value, $level+1); }else{ $inline = true; $xml_serialized_string .= htmlspecialchars($value); } $xml_serialized_string .= (!$inline ? str_repeat("\t", $level) : "") . "</$key>\r\n"; } }else{ #echo "Skipping attribute record for key $key<bR>"; } } if($level == 0){ $xml_serialized_string = "<?xml version=\"1.0\" ?>\r\n" . $xml_serialized_string; return $xml_serialized_string; }else{ return $xml_serialized_string; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h7cpA
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
   56     3      > RETURN                                                   1

Function xml_serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
2 jumps found. (Code = 44) Position 1 = 110, Position 2 = 5
Branch analysis from position: 110
2 jumps found. (Code = 43) Position 1 = 112, Position 2 = 116
Branch analysis from position: 112
Return found
Branch analysis from position: 116
Return found
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 102
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 42
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 19
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 101
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 82
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 95
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
Branch analysis from position: 95
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 95
Branch analysis from position: 89
Branch analysis from position: 95
Branch analysis from position: 101
Branch analysis from position: 48
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 60
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 101
Branch analysis from position: 62
Branch analysis from position: 101
Branch analysis from position: 60
Branch analysis from position: 52
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 19
Branch analysis from position: 42
Branch analysis from position: 19
Branch analysis from position: 42
Branch analysis from position: 102
filename:       /in/h7cpA
function name:  XML_serialize
number of ops:  118
compiled vars:  !0 = $data, !1 = $level, !2 = $prior_key, !3 = $xml_serialized_string, !4 = $inline, !5 = $numeric_array, !6 = $attributes, !7 = $key, !8 = $attr_value, !9 = $attr_name, !10 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      null
    5     3        ASSIGN                                                   !3, ''
    6     4      > JMP                                                      ->102
    7     5    >   ASSIGN                                                   !4, <false>
    8     6        ASSIGN                                                   !5, <false>
    9     7        ASSIGN                                                   !6, ''
   11     8        INIT_FCALL                                               'strstr'
          9        SEND_VAR                                                 !7
         10        SEND_VAL                                                 '+attr'
         11        DO_ICALL                                         $15     
         12        BOOL_NOT                                         ~16     $15
         13      > JMPZ                                                     ~16, ->102
   12    14    >   NOP                                                      
         15        FAST_CONCAT                                      ~17     !7, '+attr'
         16        ARRAY_KEY_EXISTS                                         ~17, !0
         17      > JMPZ                                                     ~18, ->42
   13    18    > > JMP                                                      ->30
   15    19    >   INIT_FCALL                                               'htmlspecialchars'
         20        SEND_VAR                                                 !8
         21        SEND_VAL                                                 3
         22        DO_ICALL                                         $19     
         23        ASSIGN_REF                                               !8, $19
   16    24        ROPE_INIT                                     5  ~22     '+'
         25        ROPE_ADD                                      1  ~22     ~22, !9
         26        ROPE_ADD                                      2  ~22     ~22, '%3D%22'
         27        ROPE_ADD                                      3  ~22     ~22, !8
         28        ROPE_END                                      4  ~21     ~22, '%22'
         29        ASSIGN_OP                                     8          !6, ~21
   13    30    >   INIT_FCALL_BY_NAME                                       'each'
         31        CHECK_FUNC_ARG                                           
         32        NOP                                                      
         33        FAST_CONCAT                                      ~26     !7, '+attr'
         34        FETCH_DIM_FUNC_ARG                               $27     !0, ~26
         35        SEND_FUNC_ARG                                            $27
         36        DO_FCALL                                      0  $28     
         37        FETCH_LIST_R                                     $29     $28, 0
         38        ASSIGN                                                   !9, $29
         39        FETCH_LIST_R                                     $31     $28, 1
         40        ASSIGN                                                   !8, $31
         41      > JMPNZ                                                    $28, ->19
   20    42    >   INIT_FCALL                                               'is_numeric'
         43        SEND_VAR                                                 !7
         44        DO_ICALL                                         $33     
         45      > JMPZ                                                     $33, ->48
   22    46    >   ASSIGN                                                   !7, !2
         47      > JMP                                                      ->60
   26    48    >   TYPE_CHECK                                  128  ~35     !10
         49      > JMPZ_EX                                          ~35     ~35, ->52
         50    >   ARRAY_KEY_EXISTS                                 ~36     0, !10
         51        BOOL                                             ~35     ~36
         52    > > JMPZ                                                     ~35, ->60
   28    53    >   ASSIGN                                                   !5, <true>
   29    54        INIT_FCALL_BY_NAME                                       'XML_serialize'
         55        SEND_VAR_EX                                              !10
         56        SEND_VAR_EX                                              !1
         57        SEND_VAR_EX                                              !7
         58        DO_FCALL                                      0  $38     
         59        ASSIGN_OP                                     8          !3, $38
   34    60    >   BOOL_NOT                                         ~40     !5
         61      > JMPZ                                                     ~40, ->101
   35    62    >   INIT_FCALL                                               'str_repeat'
         63        SEND_VAL                                                 '%09'
         64        SEND_VAR                                                 !1
         65        DO_ICALL                                         $41     
         66        ROPE_INIT                                     4  ~43     '%3C'
         67        ROPE_ADD                                      1  ~43     ~43, !7
         68        ROPE_ADD                                      2  ~43     ~43, !6
         69        ROPE_END                                      3  ~42     ~43, '%3E'
         70        CONCAT                                           ~45     $41, ~42
         71        ASSIGN_OP                                     8          !3, ~45
   37    72        TYPE_CHECK                                  128          !10
         73      > JMPZ                                                     ~47, ->82
   38    74    >   INIT_FCALL_BY_NAME                                       'XML_serialize'
         75        SEND_VAR_EX                                              !10
         76        ADD                                              ~48     !1, 1
         77        SEND_VAL_EX                                              ~48
         78        DO_FCALL                                      0  $49     
         79        CONCAT                                           ~50     '%0D%0A', $49
         80        ASSIGN_OP                                     8          !3, ~50
         81      > JMP                                                      ->87
   40    82    >   ASSIGN                                                   !4, <true>
   41    83        INIT_FCALL                                               'htmlspecialchars'
         84        SEND_VAR                                                 !10
         85        DO_ICALL                                         $53     
         86        ASSIGN_OP                                     8          !3, $53
   44    87    >   BOOL_NOT                                         ~55     !4
         88      > JMPZ                                                     ~55, ->95
         89    >   INIT_FCALL                                               'str_repeat'
         90        SEND_VAL                                                 '%09'
         91        SEND_VAR                                                 !1
         92        DO_ICALL                                         $56     
         93        QM_ASSIGN                                        ~57     $56
         94      > JMP                                                      ->96
         95    >   QM_ASSIGN                                        ~57     ''
         96    >   ROPE_INIT                                     3  ~59     '%3C%2F'
         97        ROPE_ADD                                      1  ~59     ~59, !7
         98        ROPE_END                                      2  ~58     ~59, '%3E%0D%0A'
         99        CONCAT                                           ~61     ~57, ~58
        100        ASSIGN_OP                                     8          !3, ~61
        101    > > JMP                                                      ->102
    6   102    >   INIT_FCALL_BY_NAME                                       'each'
        103        SEND_VAR_EX                                              !0
        104        DO_FCALL                                      0  $63     
        105        FETCH_LIST_R                                     $64     $63, 0
        106        ASSIGN                                                   !7, $64
        107        FETCH_LIST_R                                     $66     $63, 1
        108        ASSIGN                                                   !10, $66
        109      > JMPNZ                                                    $63, ->5
   50   110    >   IS_EQUAL                                                 !1, 0
        111      > JMPZ                                                     ~68, ->116
   51   112    >   CONCAT                                           ~69     '%3C%3Fxml+version%3D%221.0%22+%3F%3E%0D%0A', !3
        113        ASSIGN                                                   !3, ~69
   52   114      > RETURN_BY_REF                                            !3
        115*       JMP                                                      ->117
   54   116    > > RETURN_BY_REF                                            !3
   56   117*     > RETURN_BY_REF                                            null

End of function xml_serialize

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.34 ms | 1400 KiB | 23 Q