3v4l.org

run code in 300+ PHP versions simultaneously
<?php $replacement = 'NEW TEXT'; $html = <<<HTML <p data-edit="1">TEXT A</p> <div not-data-edit="3">TEXT C</div> <div data-edit="2">TEXT B</div> HTML; $dom = new DOMDocument; $dom->loadHTML('<div>' . $html . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query("//*[@data-edit]") as $node) { $node->nodeValue = $replacement; } var_export(substr($dom->saveHTML() ,5, -7));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/IFPIG
function name:  (null)
number of ops:  35
compiled vars:  !0 = $replacement, !1 = $html, !2 = $dom, !3 = $xpath, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'NEW+TEXT'
    4     1        ASSIGN                                                   !1, '%3Cp+data-edit%3D%221%22%3ETEXT+A%3C%2Fp%3E%0A%3Cdiv+not-data-edit%3D%223%22%3ETEXT+C%3C%2Fdiv%3E%0A%3Cdiv+data-edit%3D%222%22%3ETEXT+B%3C%2Fdiv%3E'
   10     2        NEW                                              $7      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
   11     5        INIT_METHOD_CALL                                         !2, 'loadHTML'
          6        CONCAT                                           ~10     '%3Cdiv%3E', !1
          7        CONCAT                                           ~11     ~10, '%3C%2Fdiv%3E'
          8        SEND_VAL_EX                                              ~11
          9        SEND_VAL_EX                                              8196
         10        DO_FCALL                                      0          
   12    11        NEW                                              $13     'DOMXPath'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $13
   13    15        INIT_METHOD_CALL                                         !3, 'query'
         16        SEND_VAL_EX                                              '%2F%2F%2A%5B%40data-edit%5D'
         17        DO_FCALL                                      0  $16     
         18      > FE_RESET_R                                       $17     $16, ->23
         19    > > FE_FETCH_R                                               $17, !4, ->23
   14    20    >   ASSIGN_OBJ                                               !4, 'nodeValue'
         21        OP_DATA                                                  !0
   13    22      > JMP                                                      ->19
         23    >   FE_FREE                                                  $17
   16    24        INIT_FCALL                                               'var_export'
         25        INIT_FCALL                                               'substr'
         26        INIT_METHOD_CALL                                         !2, 'saveHTML'
         27        DO_FCALL                                      0  $19     
         28        SEND_VAR                                                 $19
         29        SEND_VAL                                                 5
         30        SEND_VAL                                                 -7
         31        DO_ICALL                                         $20     
         32        SEND_VAR                                                 $20
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.07 ms | 1012 KiB | 15 Q