3v4l.org

run code in 300+ 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 = 26
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/uSNCT
function name:  (null)
number of ops:  33
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_EX                                              !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, ->26
         17    > > FE_FETCH_R                                               $11, !3, ->26
   17    18    >   INIT_FCALL                                               'trim'
         19        FETCH_OBJ_R                                      ~12     !3, 'textContent'
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                         $13     
         22        CONCAT                                           ~14     '+%2A+', $13
         23        CONCAT                                           ~15     ~14, '%0A'
         24        ECHO                                                     ~15
   16    25      > JMP                                                      ->17
         26    >   FE_FREE                                                  $11
   19    27        ECHO                                                     '%0A'
   20    28        ECHO                                                     'DOM+serialised%3A%0A'
   21    29        INIT_METHOD_CALL                                         !1, 'saveHtml'
         30        DO_FCALL                                      0  $16     
         31        ECHO                                                     $16
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.85 ms | 1452 KiB | 14 Q