3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE html> <html> <head> INSERT VALUES OF THE GIVEN PHRASE IDS :</head> <!-- <head> <link rel="stylesheet" type="text/css" href="style.css" /></head> --> <body> <form name="form" action="" method="post"> <?php $file = <<<XML <?xml version="1.0"?> <?xml-stylesheet href="catalog.xsl" type="text/xsl"?> <!DOCTYPE catalog SYSTEM "catalog.dtd"> <catalog> <product description="Cardigan Sweater" id="123" value="" product_image="cardigan.jpg"> <catalog_item gender="Men's"> <size description="Medium"> <color_swatch image="red_cardigan.jpg" id="color" value="Red"/> <color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/> </size> <size description="Large"> <color_swatch image="red_cardigan.jpg" id="color" value="Red"/> <color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/> </size> </catalog_item> </product> </catalog> XML; /** * @param SimpleXMLElement $node current node to process * @param int $level Depth in the XML tree * @param string $fieldPrefix */ function makeNodeField(SimpleXMLElement $node, $level, $fieldPrefix = "") { // Indentation with the node level $indent = str_repeat(" ", $level); echo $indent, $node->getName(), PHP_EOL; $fieldName = $fieldPrefix; // If there's an ID on the node, display it and show a text field if (isset($node['id'])) { echo $indent, strval($node['id']), ' '; if (!empty($fieldPrefix)) { $fieldName .= '_'; } $fieldName .= $node->getName() . '_' . strval($node['id']); printf('<input type="text" name="%s" value="%s" /><br/>', $fieldName, strval($node['value'])); echo PHP_EOL; } $count = 0; foreach ($node as $childNode) { // put a prefix in the children field name to get a valid field name for POST $childPrefix = $fieldName; if (!empty($fieldPrefix)) { $childPrefix = $fieldName . '_' . $count++; } makeNodeField($childNode, $level + 1, $childPrefix); } } $xml = simplexml_load_string($file); makeNodeField($xml, 0); ?> </form> </body> </html>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UspVk
function name:  (null)
number of ops:  12
compiled vars:  !0 = $file, !1 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3C%21DOCTYPE+html%3E%0A%3Chtml%3E%0A%3Chead%3E+INSERT+VALUES+OF+THE+GIVEN+PHRASE+IDS+%3A%3C%2Fhead%3E%0A%3C%21--+%3Chead%3E+%3Clink+rel%3D%22stylesheet%22+type%3D%22text%2Fcss%22+href%3D%22style.css%22+%2F%3E%3C%2Fhead%3E+--%3E%0A%3Cbody%3E%0A%3Cform+name%3D%22form%22+action%3D%22%22+method%3D%22post%22%3E%0A++++'
    9     1        ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3C%3Fxml-stylesheet+href%3D%22catalog.xsl%22+type%3D%22text%2Fxsl%22%3F%3E%0A%3C%21DOCTYPE+catalog+SYSTEM+%22catalog.dtd%22%3E%0A%3Ccatalog%3E%0A+++%3Cproduct+description%3D%22Cardigan+Sweater%22+id%3D%22123%22+value%3D%22%22+product_image%3D%22cardigan.jpg%22%3E%0A++++++%3Ccatalog_item+gender%3D%22Men%27s%22%3E%0A+++++++++%3Csize+description%3D%22Medium%22%3E%0A++++++++++++%3Ccolor_swatch+image%3D%22red_cardigan.jpg%22+id%3D%22color%22+value%3D%22Red%22%2F%3E%0A+++++++++++++%3Ccolor_swatch+image%3D%22burgundy_cardigan.jpg%22+id%3D%22color%22+value%3D%22burgundy%22%2F%3E%0A+++++++++%3C%2Fsize%3E%0A+++++++++%3Csize+description%3D%22Large%22%3E%0A+++++++++++%3Ccolor_swatch+image%3D%22red_cardigan.jpg%22+id%3D%22color%22+value%3D%22Red%22%2F%3E%0A++++++++++++%3Ccolor_swatch+image%3D%22burgundy_cardigan.jpg%22+id%3D%22color%22+value%3D%22burgundy%22%2F%3E%0A+++++++++%3C%2Fsize%3E%0A++++++%3C%2Fcatalog_item%3E%0A+++%3C%2Fproduct%3E%0A%3C%2Fcatalog%3E'
   67     2        INIT_FCALL                                               'simplexml_load_string'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   69     6        INIT_FCALL                                               'makenodefield'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 0
          9        DO_FCALL                                      0          
   72    10        ECHO                                                     '%3C%2Fform%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   74    11      > RETURN                                                   1

Function makenodefield:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 40
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 58
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 58
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 51
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 51
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 25
Branch analysis from position: 40
filename:       /in/UspVk
function name:  makeNodeField
number of ops:  60
compiled vars:  !0 = $node, !1 = $level, !2 = $fieldPrefix, !3 = $indent, !4 = $fieldName, !5 = $count, !6 = $childNode, !7 = $childPrefix
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      ''
   37     3        INIT_FCALL                                               'str_repeat'
          4        SEND_VAL                                                 '++++'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !3, $8
   39     8        ECHO                                                     !3
          9        INIT_METHOD_CALL                                         !0, 'getName'
         10        DO_FCALL                                      0  $10     
         11        ECHO                                                     $10
         12        ECHO                                                     '%0A'
   41    13        ASSIGN                                                   !4, !2
   44    14        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'id'
         15      > JMPZ                                                     ~12, ->40
   45    16    >   ECHO                                                     !3
         17        FETCH_DIM_R                                      ~13     !0, 'id'
         18        CAST                                          6  ~14     ~13
         19        ECHO                                                     ~14
         20        ECHO                                                     '+'
   46    21        ISSET_ISEMPTY_CV                                 ~15     !2
         22        BOOL_NOT                                         ~16     ~15
         23      > JMPZ                                                     ~16, ->25
   47    24    >   ASSIGN_OP                                     8          !4, '_'
   49    25    >   INIT_METHOD_CALL                                         !0, 'getName'
         26        DO_FCALL                                      0  $18     
         27        CONCAT                                           ~19     $18, '_'
         28        FETCH_DIM_R                                      ~20     !0, 'id'
         29        CAST                                          6  ~21     ~20
         30        CONCAT                                           ~22     ~19, ~21
         31        ASSIGN_OP                                     8          !4, ~22
   50    32        INIT_FCALL                                               'printf'
         33        SEND_VAL                                                 '%3Cinput+type%3D%22text%22+name%3D%22%25s%22+value%3D%22%25s%22+%2F%3E%3Cbr%2F%3E'
         34        SEND_VAR                                                 !4
         35        FETCH_DIM_R                                      ~24     !0, 'value'
         36        CAST                                          6  ~25     ~24
         37        SEND_VAL                                                 ~25
         38        DO_ICALL                                                 
   51    39        ECHO                                                     '%0A'
   54    40    >   ASSIGN                                                   !5, 0
   55    41      > FE_RESET_R                                       $28     !0, ->58
         42    > > FE_FETCH_R                                               $28, !6, ->58
   57    43    >   ASSIGN                                                   !7, !4
   59    44        ISSET_ISEMPTY_CV                                 ~30     !2
         45        BOOL_NOT                                         ~31     ~30
         46      > JMPZ                                                     ~31, ->51
   60    47    >   CONCAT                                           ~32     !4, '_'
         48        POST_INC                                         ~33     !5
         49        CONCAT                                           ~34     ~32, ~33
         50        ASSIGN                                                   !7, ~34
   62    51    >   INIT_FCALL_BY_NAME                                       'makeNodeField'
         52        SEND_VAR_EX                                              !6
         53        ADD                                              ~36     !1, 1
         54        SEND_VAL_EX                                              ~36
         55        SEND_VAR_EX                                              !7
         56        DO_FCALL                                      0          
   55    57      > JMP                                                      ->42
         58    >   FE_FREE                                                  $28
   65    59      > RETURN                                                   null

End of function makenodefield

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.02 ms | 1013 KiB | 17 Q