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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.39 ms | 1456 KiB | 14 Q