3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument; $xpath = new DOMXPath($doc); $frag = $doc->createDocumentFragment(); $frag->appendXML(<<<'HTML' <div id="article"> <p>Some text</p> <p>More text</p> <pre><code> echo $variable; </code></pre> </div> HTML ); $text_nodes = $xpath->query('descendant::text()[not(ancestor::pre)]', $frag); foreach ($text_nodes as $text_node) { $text_node->data = strrev($text_node->data); } echo $doc->saveHTML($frag->firstChild);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/J0Dch
function name:  (null)
number of ops:  35
compiled vars:  !0 = $doc, !1 = $xpath, !2 = $frag, !3 = $text_nodes, !4 = $text_node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $5      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
    4     3        NEW                                              $8      'DOMXPath'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $8
    6     7        INIT_METHOD_CALL                                         !0, 'createDocumentFragment'
          8        DO_FCALL                                      0  $11     
          9        ASSIGN                                                   !2, $11
    7    10        INIT_METHOD_CALL                                         !2, 'appendXML'
    8    11        SEND_VAL_EX                                              '%3Cdiv+id%3D%22article%22%3E%0A++++%3Cp%3ESome+text%3C%2Fp%3E%0A++++%3Cp%3EMore+text%3C%2Fp%3E%0A++++%3Cpre%3E%3Ccode%3E%0A+++++++++echo+%24variable%3B%0A++++%3C%2Fcode%3E%3C%2Fpre%3E%0A%3C%2Fdiv%3E'
         12        DO_FCALL                                      0          
   18    13        INIT_METHOD_CALL                                         !1, 'query'
         14        SEND_VAL_EX                                              'descendant%3A%3Atext%28%29%5Bnot%28ancestor%3A%3Apre%29%5D'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0  $14     
         17        ASSIGN                                                   !3, $14
   19    18      > FE_RESET_R                                       $16     !3, ->27
         19    > > FE_FETCH_R                                               $16, !4, ->27
   20    20    >   INIT_FCALL                                               'strrev'
         21        FETCH_OBJ_R                                      ~18     !4, 'data'
         22        SEND_VAL                                                 ~18
         23        DO_ICALL                                         $19     
         24        ASSIGN_OBJ                                               !4, 'data'
         25        OP_DATA                                                  $19
   19    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $16
   23    28        INIT_METHOD_CALL                                         !0, 'saveHTML'
         29        CHECK_FUNC_ARG                                           
         30        FETCH_OBJ_FUNC_ARG                               $20     !2, 'firstChild'
         31        SEND_FUNC_ARG                                            $20
         32        DO_FCALL                                      0  $21     
         33        ECHO                                                     $21
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.14 ms | 1396 KiB | 15 Q