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/HTMLDocument (lexbor) $newDom = \DOM\HTMLDocument::createFromString($html); $paragraphs = $newDom->getElementsByTagName('p'); echo "\n"; echo "DOM\HTMLDocument parsing (lexbor)\n"; echo "---------------------------------\n"; echo "{$paragraphs->length} paragraph elements found.\n"; // 2 paragraphs found (correct) foreach ($paragraphs as $p) { echo " * " . trim($p->textContent) . "\n"; } echo "\n"; echo "DOM serialised:\n"; echo $newDom->saveHtml();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/uSNCT
function name:  (null)
number of ops:  31
compiled vars:  !0 = $html, !1 = $newDom, !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'
    9     1        INIT_STATIC_METHOD_CALL                                      'DOM%5CHTMLDocument', 'createFromString'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $5      
          4        ASSIGN                                                       !1, $5
   10     5        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
          6        SEND_VAL_EX                                                  'p'
          7        DO_FCALL                                          0  $7      
          8        ASSIGN                                                       !2, $7
   11     9        ECHO                                                         '%0A'
   12    10        ECHO                                                         'DOM%5CHTMLDocument+parsing+%28lexbor%29%0A'
   13    11        ECHO                                                         '---------------------------------%0A'
   14    12        FETCH_OBJ_R                                          ~9      !2, 'length'
         13        NOP                                                          
         14        FAST_CONCAT                                          ~10     ~9, '+paragraph+elements+found.%0A'
         15        ECHO                                                         ~10
   16    16      > FE_RESET_R                                           $11     !2, ->24
         17    > > FE_FETCH_R                                                   $11, !3, ->24
   17    18    >   FETCH_OBJ_R                                          ~12     !3, 'textContent'
         19        FRAMELESS_ICALL_1                trim                ~13     ~12
         20        CONCAT                                               ~14     '+%2A+', ~13
         21        CONCAT                                               ~15     ~14, '%0A'
         22        ECHO                                                         ~15
   16    23      > JMP                                                          ->17
         24    >   FE_FREE                                                      $11
   19    25        ECHO                                                         '%0A'
   20    26        ECHO                                                         'DOM+serialised%3A%0A'
   21    27        INIT_METHOD_CALL                                             !1, 'saveHtml'
         28        DO_FCALL                                          0  $16     
         29        ECHO                                                         $16
         30      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.35 ms | 1322 KiB | 13 Q