3v4l.org

run code in 300+ PHP versions simultaneously
<?php //this code will append a &mobileapp to every https://example.com url and http://foobar.com url ob_start(); ?> <html> <head> </head> <body> <a href="http://foobar.com"> http://www.example.com/~hillybilly/foobar.php silly silly </body> </html> <?php $html = ob_get_clean(); $append = 'mobileapp'; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXpath($doc); $elements = $xpath->query('//*[@href | @src | @action]'); if (!is_null($elements)) { foreach ($elements as $element) { var_dump($element); switch ($element->nodeName) { case 'a': $element->setAttribute('href', $element->getAttribute('href') . '&' . $append); } } } echo $doc->saveHtml();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 45
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 44
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 44
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 45
filename:       /in/DAZXp
function name:  (null)
number of ops:  49
compiled vars:  !0 = $html, !1 = $append, !2 = $doc, !3 = $xpath, !4 = $elements, !5 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ob_start'
          1        DO_ICALL                                                 
    5     2        ECHO                                                     '%3Chtml%3E%0A++++%3Chead%3E%0A++++%3C%2Fhead%3E%0A++++%3Cbody%3E%0A%3Ca+href%3D%22http%3A%2F%2Ffoobar.com%22%3E%0Ahttp%3A%2F%2Fwww.example.com%2F%7Ehillybilly%2Ffoobar.php%0Asilly+silly%0A++++%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A'
   15     3        INIT_FCALL                                               'ob_get_clean'
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !0, $7
   16     6        ASSIGN                                                   !1, 'mobileapp'
   17     7        NEW                                              $10     'DOMDocument'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $10
   18    10        INIT_METHOD_CALL                                         !2, 'loadHTML'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
   19    13        NEW                                              $14     'DOMXpath'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !3, $14
   23    17        INIT_METHOD_CALL                                         !3, 'query'
         18        SEND_VAL_EX                                              '%2F%2F%2A%5B%40href+%7C+%40src+%7C+%40action%5D'
         19        DO_FCALL                                      0  $17     
         20        ASSIGN                                                   !4, $17
   24    21        TYPE_CHECK                                    2  ~19     !4
         22        BOOL_NOT                                         ~20     ~19
         23      > JMPZ                                                     ~20, ->45
   25    24    > > FE_RESET_R                                       $21     !4, ->44
         25    > > FE_FETCH_R                                               $21, !5, ->44
   26    26    >   INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !5
         28        DO_ICALL                                                 
   27    29        FETCH_OBJ_R                                      ~23     !5, 'nodeName'
   28    30        CASE                                                     ~23, 'a'
         31      > JMPNZ                                                    ~24, ->33
         32    > > JMP                                                      ->42
   29    33    >   INIT_METHOD_CALL                                         !5, 'setAttribute'
         34        SEND_VAL_EX                                              'href'
         35        INIT_METHOD_CALL                                         !5, 'getAttribute'
         36        SEND_VAL_EX                                              'href'
         37        DO_FCALL                                      0  $25     
         38        CONCAT                                           ~26     $25, '%26'
         39        CONCAT                                           ~27     ~26, !1
         40        SEND_VAL_EX                                              ~27
         41        DO_FCALL                                      0          
         42    >   FREE                                                     ~23
   25    43      > JMP                                                      ->25
         44    >   FE_FREE                                                  $21
   33    45    >   INIT_METHOD_CALL                                         !2, 'saveHtml'
         46        DO_FCALL                                      0  $29     
         47        ECHO                                                     $29
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.59 ms | 1400 KiB | 19 Q