3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Create a DOM Document $dom = new DomDocument(); // Load your HTML $dom->loadHTML('<form class="search-form"> <meta itemprop="target"> <input type="search"> <input type="submit"> </form>'); // Create a new <span> $span = $dom->createElement('span', 'hello'); // Grab the <input elements (we dont have an ID) $inputs = $dom->getElementsByTagName('input'); // Add the <span> between the inputs $inputs->item(0)->parentNode->insertBefore($span, $inputs->item(1)); // By default when you loadHTML(), it generates doctype, html, head, and body tags. remove them! $dom->removeChild($dom->doctype); $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); // Finally get the HTML $html = $dom->saveHTML(); // And output / return / whatever echo $html;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ats7D
function name:  (null)
number of ops:  46
compiled vars:  !0 = $dom, !1 = $span, !2 = $inputs, !3 = $html
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   NEW                                                  $4      'DomDocument'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $4
    7     3        INIT_METHOD_CALL                                             !0, 'loadHTML'
          4        SEND_VAL_EX                                                  '%3Cform+class%3D%22search-form%22%3E%0A++%3Cmeta+itemprop%3D%22target%22%3E%0A++%3Cinput+type%3D%22search%22%3E%0A++%3Cinput+type%3D%22submit%22%3E%0A%3C%2Fform%3E'
          5        DO_FCALL                                          0          
   14     6        INIT_METHOD_CALL                                             !0, 'createElement'
          7        SEND_VAL_EX                                                  'span'
          8        SEND_VAL_EX                                                  'hello'
          9        DO_FCALL                                          0  $8      
         10        ASSIGN                                                       !1, $8
   17    11        INIT_METHOD_CALL                                             !0, 'getElementsByTagName'
         12        SEND_VAL_EX                                                  'input'
         13        DO_FCALL                                          0  $10     
         14        ASSIGN                                                       !2, $10
   20    15        INIT_METHOD_CALL                                             !2, 'item'
         16        SEND_VAL_EX                                                  0
         17        DO_FCALL                                          0  $12     
         18        FETCH_OBJ_R                                          ~13     $12, 'parentNode'
         19        INIT_METHOD_CALL                                             ~13, 'insertBefore'
         20        SEND_VAR_EX                                                  !1
         21        INIT_METHOD_CALL                                             !2, 'item'
         22        SEND_VAL_EX                                                  1
         23        DO_FCALL                                          0  $14     
         24        SEND_VAR_NO_REF_EX                                           $14
         25        DO_FCALL                                          0          
   23    26        INIT_METHOD_CALL                                             !0, 'removeChild'
         27        CHECK_FUNC_ARG                                               
         28        FETCH_OBJ_FUNC_ARG                                   $16     !0, 'doctype'
         29        SEND_FUNC_ARG                                                $16
         30        DO_FCALL                                          0          
   24    31        INIT_METHOD_CALL                                             !0, 'replaceChild'
         32        CHECK_FUNC_ARG                                               
         33        FETCH_OBJ_FUNC_ARG                                   $18     !0, 'firstChild'
         34        FETCH_OBJ_FUNC_ARG                                   $19     $18, 'firstChild'
         35        FETCH_OBJ_FUNC_ARG                                   $20     $19, 'firstChild'
         36        SEND_FUNC_ARG                                                $20
         37        CHECK_FUNC_ARG                                               
         38        FETCH_OBJ_FUNC_ARG                                   $21     !0, 'firstChild'
         39        SEND_FUNC_ARG                                                $21
         40        DO_FCALL                                          0          
   27    41        INIT_METHOD_CALL                                             !0, 'saveHTML'
         42        DO_FCALL                                          0  $23     
         43        ASSIGN                                                       !3, $23
   30    44        ECHO                                                         !3
         45      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.09 ms | 2085 KiB | 13 Q