3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = '<var>One</var> <var>Two</var>'; // Works fine ($domA = new DOMDocument('1.0', 'UTF-8'))->loadHTML($a); foreach ((new DOMXPath($domA))->query('//var') as $var) { $var->replaceWith($domA->createElement('p', $var->nodeValue)); } var_dump($domA->saveHTML()); $b = '<var>One</var><var>Two</var>'; // Causes a 'double free' error ($domB = new DOMDocument('1.0', 'UTF-8'))->loadHTML($b); foreach ((new DOMXPath($domB))->query('//var') as $var) { $var->replaceWith($domB->createElement('p', $var->nodeValue)); } var_dump($domB->saveHTML());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 49, Position 2 = 60
Branch analysis from position: 49
2 jumps found. (Code = 78) Position 1 = 50, Position 2 = 60
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 27
filename:       /in/Y2vJc
function name:  (null)
number of ops:  67
compiled vars:  !0 = $a, !1 = $domA, !2 = $var, !3 = $b, !4 = $domB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cvar%3EOne%3C%2Fvar%3E+%3Cvar%3ETwo%3C%2Fvar%3E'
    5     1        NEW                                              $6      'DOMDocument'
          2        SEND_VAL_EX                                              '1.0'
          3        SEND_VAL_EX                                              'UTF-8'
          4        DO_FCALL                                      0          
          5        ASSIGN                                           ~8      !1, $6
          6        INIT_METHOD_CALL                                         ~8, 'loadHTML'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
    7     9        NEW                                              $10     'DOMXPath'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12        INIT_METHOD_CALL                                         $10, 'query'
         13        SEND_VAL_EX                                              '%2F%2Fvar'
         14        DO_FCALL                                      0  $12     
         15      > FE_RESET_R                                       $13     $12, ->27
         16    > > FE_FETCH_R                                               $13, !2, ->27
    8    17    >   INIT_METHOD_CALL                                         !2, 'replaceWith'
         18        INIT_METHOD_CALL                                         !1, 'createElement'
         19        SEND_VAL_EX                                              'p'
         20        CHECK_FUNC_ARG                                           
         21        FETCH_OBJ_FUNC_ARG                               $14     !2, 'nodeValue'
         22        SEND_FUNC_ARG                                            $14
         23        DO_FCALL                                      0  $15     
         24        SEND_VAR_NO_REF_EX                                       $15
         25        DO_FCALL                                      0          
    7    26      > JMP                                                      ->16
         27    >   FE_FREE                                                  $13
   11    28        INIT_FCALL                                               'var_dump'
         29        INIT_METHOD_CALL                                         !1, 'saveHTML'
         30        DO_FCALL                                      0  $17     
         31        SEND_VAR                                                 $17
         32        DO_ICALL                                                 
   13    33        ASSIGN                                                   !3, '%3Cvar%3EOne%3C%2Fvar%3E%3Cvar%3ETwo%3C%2Fvar%3E'
   15    34        NEW                                              $20     'DOMDocument'
         35        SEND_VAL_EX                                              '1.0'
         36        SEND_VAL_EX                                              'UTF-8'
         37        DO_FCALL                                      0          
         38        ASSIGN                                           ~22     !4, $20
         39        INIT_METHOD_CALL                                         ~22, 'loadHTML'
         40        SEND_VAR_EX                                              !3
         41        DO_FCALL                                      0          
   17    42        NEW                                              $24     'DOMXPath'
         43        SEND_VAR_EX                                              !4
         44        DO_FCALL                                      0          
         45        INIT_METHOD_CALL                                         $24, 'query'
         46        SEND_VAL_EX                                              '%2F%2Fvar'
         47        DO_FCALL                                      0  $26     
         48      > FE_RESET_R                                       $27     $26, ->60
         49    > > FE_FETCH_R                                               $27, !2, ->60
   18    50    >   INIT_METHOD_CALL                                         !2, 'replaceWith'
         51        INIT_METHOD_CALL                                         !4, 'createElement'
         52        SEND_VAL_EX                                              'p'
         53        CHECK_FUNC_ARG                                           
         54        FETCH_OBJ_FUNC_ARG                               $28     !2, 'nodeValue'
         55        SEND_FUNC_ARG                                            $28
         56        DO_FCALL                                      0  $29     
         57        SEND_VAR_NO_REF_EX                                       $29
         58        DO_FCALL                                      0          
   17    59      > JMP                                                      ->49
         60    >   FE_FREE                                                  $27
   21    61        INIT_FCALL                                               'var_dump'
         62        INIT_METHOD_CALL                                         !4, 'saveHTML'
         63        DO_FCALL                                      0  $31     
         64        SEND_VAR                                                 $31
         65        DO_ICALL                                                 
         66      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
210.56 ms | 1002 KiB | 14 Q