3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div title="Cool stuff" alt="Cool stuff"><a title="another stuff">......</a></div> HTML; $newTitle = 'My new title'; $dom = new DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query('//@title') as $attr) { $attr->value = $newTitle; } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/3ZAQq
function name:  (null)
number of ops:  26
compiled vars:  !0 = $html, !1 = $newTitle, !2 = $dom, !3 = $xpath, !4 = $attr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+title%3D%22Cool+stuff%22+alt%3D%22Cool+stuff%22%3E%3Ca+title%3D%22another+stuff%22%3E......%3C%2Fa%3E%3C%2Fdiv%3E'
    6     1        ASSIGN                                                   !1, 'My+new+title'
    8     2        NEW                                              $7      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
    9     5        INIT_METHOD_CALL                                         !2, 'loadHTML'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAL_EX                                              8196
          8        DO_FCALL                                      0          
   10     9        NEW                                              $11     'DOMXPath'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $11
   11    13        INIT_METHOD_CALL                                         !3, 'query'
         14        SEND_VAL_EX                                              '%2F%2F%40title'
         15        DO_FCALL                                      0  $14     
         16      > FE_RESET_R                                       $15     $14, ->21
         17    > > FE_FETCH_R                                               $15, !4, ->21
   12    18    >   ASSIGN_OBJ                                               !4, 'value'
         19        OP_DATA                                                  !1
   11    20      > JMP                                                      ->17
         21    >   FE_FREE                                                  $15
   14    22        INIT_METHOD_CALL                                         !2, 'saveHTML'
         23        DO_FCALL                                      0  $17     
         24        ECHO                                                     $17
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.58 ms | 1069 KiB | 13 Q