3v4l.org

run code in 300+ PHP versions simultaneously
<?php function modify_href( $href ) { return $href . '/modified'; } $string = '<div> <a href="http://somelink" class="possible-class">text</a> <a href="http://anotherlink">other text</a> </div>'; $doc = new DomDocument(); $fragment = $doc->createDocumentFragment(); $fragment->appendXML($string); $doc->appendChild($fragment); $xpath = new DOMXPath($doc); $elements = $xpath->query("//div/a"); foreach ($elements as $element) { $element->setAttribute("href", modify_href($element->getAttribute("href"))); } echo $doc->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 34
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 34
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/VVeLa
function name:  (null)
number of ops:  39
compiled vars:  !0 = $string, !1 = $doc, !2 = $fragment, !3 = $xpath, !4 = $elements, !5 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, '%3Cdiv%3E%0A++++%3Ca+href%3D%22http%3A%2F%2Fsomelink%22+class%3D%22possible-class%22%3Etext%3C%2Fa%3E%0A++++%3Ca+href%3D%22http%3A%2F%2Fanotherlink%22%3Eother+text%3C%2Fa%3E%0A%3C%2Fdiv%3E'
   12     1        NEW                                              $7      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   13     4        INIT_METHOD_CALL                                         !1, 'createDocumentFragment'
          5        DO_FCALL                                      0  $10     
          6        ASSIGN                                                   !2, $10
   14     7        INIT_METHOD_CALL                                         !2, 'appendXML'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   15    10        INIT_METHOD_CALL                                         !1, 'appendChild'
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0          
   16    13        NEW                                              $14     'DOMXPath'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !3, $14
   17    17        INIT_METHOD_CALL                                         !3, 'query'
         18        SEND_VAL_EX                                              '%2F%2Fdiv%2Fa'
         19        DO_FCALL                                      0  $17     
         20        ASSIGN                                                   !4, $17
   18    21      > FE_RESET_R                                       $19     !4, ->34
         22    > > FE_FETCH_R                                               $19, !5, ->34
   19    23    >   INIT_METHOD_CALL                                         !5, 'setAttribute'
         24        SEND_VAL_EX                                              'href'
         25        INIT_FCALL                                               'modify_href'
         26        INIT_METHOD_CALL                                         !5, 'getAttribute'
         27        SEND_VAL_EX                                              'href'
         28        DO_FCALL                                      0  $20     
         29        SEND_VAR                                                 $20
         30        DO_FCALL                                      0  $21     
         31        SEND_VAR_NO_REF_EX                                       $21
         32        DO_FCALL                                      0          
   18    33      > JMP                                                      ->22
         34    >   FE_FREE                                                  $19
   21    35        INIT_METHOD_CALL                                         !1, 'saveHTML'
         36        DO_FCALL                                      0  $23     
         37        ECHO                                                     $23
         38      > RETURN                                                   1

Function modify_href:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VVeLa
function name:  modify_href
number of ops:  4
compiled vars:  !0 = $href
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        CONCAT                                           ~1      !0, '%2Fmodified'
          2      > RETURN                                                   ~1
    5     3*     > RETURN                                                   null

End of function modify_href

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.8 ms | 1011 KiB | 14 Q