3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <img src="icons/example.svg"> <a href="http://www.example.com">a link</a> <link href="css/example.css"> <iframe src="http://www.example.com/default.htm"></iframe> </div> HTML; $dom = new DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query('//img/@src | //link/@href') as $attr) { $attr->value = "{{asset('" . $attr->value . ")'}}"; } echo substr($dom->saveXML(), 38); // remove the leading '<?xml version="1.0" standalone="yes"?>'
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/Cjqj5
function name:  (null)
number of ops:  33
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $attr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv%3E%0A++++%3Cimg+src%3D%22icons%2Fexample.svg%22%3E%0A++++%3Ca+href%3D%22http%3A%2F%2Fwww.example.com%22%3Ea+link%3C%2Fa%3E%0A++++%3Clink+href%3D%22css%2Fexample.css%22%3E%0A++++%3Ciframe+src%3D%22http%3A%2F%2Fwww.example.com%2Fdefault.htm%22%3E%3C%2Fiframe%3E%0A%3C%2Fdiv%3E'
   12     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   13     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
   14     8        NEW                                              $9      'DOMXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $9
   15    12        INIT_METHOD_CALL                                         !2, 'query'
         13        SEND_VAL_EX                                              '%2F%2Fimg%2F%40src+%7C+%2F%2Flink%2F%40href'
         14        DO_FCALL                                      0  $12     
         15      > FE_RESET_R                                       $13     $12, ->23
         16    > > FE_FETCH_R                                               $13, !3, ->23
   16    17    >   FETCH_OBJ_R                                      ~15     !3, 'value'
         18        CONCAT                                           ~16     '%7B%7Basset%28%27', ~15
         19        CONCAT                                           ~17     ~16, '%29%27%7D%7D'
         20        ASSIGN_OBJ                                               !3, 'value'
         21        OP_DATA                                                  ~17
   15    22      > JMP                                                      ->16
         23    >   FE_FREE                                                  $13
   18    24        INIT_FCALL                                               'substr'
         25        INIT_METHOD_CALL                                         !1, 'saveXML'
         26        DO_FCALL                                      0  $18     
         27        SEND_VAR                                                 $18
         28        SEND_VAL                                                 38
         29        DO_ICALL                                         $19     
         30        ECHO                                                     $19
         31        ECHO                                                     '%27'
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.53 ms | 1396 KiB | 15 Q