3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = " <html> <body> <div id='div1'></div> <div id='div2'> Some text <span>Inside a span</span> <div>Nested div</div> </div> </body> </html>"; $doc = new DOMDocument(); $doc->loadHTML($html); $div = $doc->getElementById("div2"); echo $div->ownerDocument->saveHTML($div);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GCbJk
function name:  (null)
number of ops:  17
compiled vars:  !0 = $html, !1 = $doc, !2 = $div
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%0A%3Chtml%3E%0A++++%3Cbody%3E%0A++++++++%3Cdiv+id%3D%27div1%27%3E%3C%2Fdiv%3E%0A++++++++%3Cdiv+id%3D%27div2%27%3E%0A++++++++++++Some+text%0A++++++++++++%3Cspan%3EInside+a+span%3C%2Fspan%3E%0A++++++++++++%3Cdiv%3ENested+div%3C%2Fdiv%3E%0A++++++++%3C%2Fdiv%3E%0A++++%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   14     1        NEW                                                  $4      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $4
   15     4        INIT_METHOD_CALL                                             !1, 'loadHTML'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
   16     7        INIT_METHOD_CALL                                             !1, 'getElementById'
          8        SEND_VAL_EX                                                  'div2'
          9        DO_FCALL                                          0  $8      
         10        ASSIGN                                                       !2, $8
   18    11        FETCH_OBJ_R                                          ~10     !2, 'ownerDocument'
         12        INIT_METHOD_CALL                                             ~10, 'saveHTML'
         13        SEND_VAR_EX                                                  !2
         14        DO_FCALL                                          0  $11     
         15        ECHO                                                         $11
         16      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.46 ms | 2966 KiB | 13 Q