3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<html><body><p>This is a <em>test</em>.</p></body></html>'; $dom = new domdocument; $dom->loadhtml($html); $p = $dom->getelementsbytagname('p')[0]; $text = ''; foreach ($p->childNodes as $node) { if ($node->nodeName === '#text') { $text .= $node->textContent; } if ($node->nodeName === 'em') { $text .= "*{$node->textContent}*"; } } echo $text;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 30
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 29
Branch analysis from position: 21
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/nXmO4
function name:  (null)
number of ops:  33
compiled vars:  !0 = $html, !1 = $dom, !2 = $p, !3 = $text, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%3Cbody%3E%3Cp%3EThis+is+a+%3Cem%3Etest%3C%2Fem%3E.%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E'
    4     1        NEW                                              $6      'domdocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
    5     4        INIT_METHOD_CALL                                         !1, 'loadhtml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    6     7        INIT_METHOD_CALL                                         !1, 'getelementsbytagname'
          8        SEND_VAL_EX                                              'p'
          9        DO_FCALL                                      0  $10     
         10        FETCH_DIM_R                                      ~11     $10, 0
         11        ASSIGN                                                   !2, ~11
    8    12        ASSIGN                                                   !3, ''
    9    13        FETCH_OBJ_R                                      ~14     !2, 'childNodes'
         14      > FE_RESET_R                                       $15     ~14, ->30
         15    > > FE_FETCH_R                                               $15, !4, ->30
   10    16    >   FETCH_OBJ_R                                      ~16     !4, 'nodeName'
         17        IS_IDENTICAL                                             ~16, '%23text'
         18      > JMPZ                                                     ~17, ->21
   11    19    >   FETCH_OBJ_R                                      ~18     !4, 'textContent'
         20        ASSIGN_OP                                     8          !3, ~18
   13    21    >   FETCH_OBJ_R                                      ~20     !4, 'nodeName'
         22        IS_IDENTICAL                                             ~20, 'em'
         23      > JMPZ                                                     ~21, ->29
   14    24    >   ROPE_INIT                                     3  ~24     '%2A'
         25        FETCH_OBJ_R                                      ~22     !4, 'textContent'
         26        ROPE_ADD                                      1  ~24     ~24, ~22
         27        ROPE_END                                      2  ~23     ~24, '%2A'
         28        ASSIGN_OP                                     8          !3, ~23
    9    29    > > JMP                                                      ->15
         30    >   FE_FREE                                                  $15
   18    31        ECHO                                                     !3
   19    32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.62 ms | 1386 KiB | 13 Q