3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = '<!DOCTYPE html> <title>Valid HTML5 Document</title> <p>Paragraph 1</p> <script>console.log("</html>Console log text");</script> <p>Paragraph 2</p>'; $dom = new DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $dom->loadHtml($html); $paragraphs = $dom->getElementsByTagName('p'); echo "DOMDocument parsing (libxml)\n"; echo "----------------------------\n"; echo "{$paragraphs->length} paragraph elements found:\n"; // 3 paragraphs found but we expected 2 foreach ($paragraphs as $p) { echo " * " . trim($p->textContent) . "\n"; } echo "\n"; echo "DOM serialised:\n"; echo $dom->saveHtml();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/OkmpO
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $dom, !2 = $paragraphs, !3 = $p
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%3C%21DOCTYPE+html%3E%0A%3Ctitle%3EValid+HTML5+Document%3C%2Ftitle%3E%0A%3Cp%3EParagraph+1%3C%2Fp%3E%0A%3Cscript%3Econsole.log%28%22%3C%2Fhtml%3EConsole+log+text%22%29%3B%3C%2Fscript%3E%0A%3Cp%3EParagraph+2%3C%2Fp%3E'
    8     1        NEW                                                  $5      'DOMDocument'
          2        SEND_VAL_EX                                                  '1.0'
          3        SEND_VAL_EX                                                  'UTF-8'
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !1, $5
    9     6        ASSIGN_OBJ                                                   !1, 'formatOutput'
          7        OP_DATA                                                      <true>
   10     8        INIT_METHOD_CALL                                             !1, 'loadHtml'
          9        SEND_VAR_EX                                                  !0
         10        DO_FCALL                                          0          
   11    11        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
         12        SEND_VAL_EX                                                  'p'
         13        DO_FCALL                                          0  $10     
         14        ASSIGN                                                       !2, $10
   12    15        ECHO                                                         'DOMDocument+parsing+%28libxml%29%0A'
   13    16        ECHO                                                         '----------------------------%0A'
   14    17        FETCH_OBJ_R                                          ~12     !2, 'length'
         18        NOP                                                          
         19        FAST_CONCAT                                          ~13     ~12, '+paragraph+elements+found%3A%0A'
         20        ECHO                                                         ~13
   16    21      > FE_RESET_R                                           $14     !2, ->29
         22    > > FE_FETCH_R                                                   $14, !3, ->29
   17    23    >   FETCH_OBJ_R                                          ~15     !3, 'textContent'
         24        FRAMELESS_ICALL_1                trim                ~16     ~15
         25        CONCAT                                               ~17     '+%2A+', ~16
         26        CONCAT                                               ~18     ~17, '%0A'
         27        ECHO                                                         ~18
   16    28      > JMP                                                          ->22
         29    >   FE_FREE                                                      $14
   19    30        ECHO                                                         '%0A'
   20    31        ECHO                                                         'DOM+serialised%3A%0A'
   21    32        INIT_METHOD_CALL                                             !1, 'saveHtml'
         33        DO_FCALL                                          0  $19     
         34        ECHO                                                         $19
         35      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.86 ms | 1492 KiB | 13 Q