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) { 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 = 42
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 41
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 41
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 42
filename:       /in/XRDQq
function name:  (null)
number of ops:  46
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, ->42
   25    24    > > FE_RESET_R                                       $21     !4, ->41
         25    > > FE_FETCH_R                                               $21, !5, ->41
   26    26    >   FETCH_OBJ_R                                      ~22     !5, 'nodeName'
   27    27        CASE                                                     ~22, 'a'
         28      > JMPNZ                                                    ~23, ->30
         29    > > JMP                                                      ->39
   28    30    >   INIT_METHOD_CALL                                         !5, 'setAttribute'
         31        SEND_VAL_EX                                              'href'
         32        INIT_METHOD_CALL                                         !5, 'getAttribute'
         33        SEND_VAL_EX                                              'href'
         34        DO_FCALL                                      0  $24     
         35        CONCAT                                           ~25     $24, '%26'
         36        CONCAT                                           ~26     ~25, !1
         37        SEND_VAL_EX                                              ~26
         38        DO_FCALL                                      0          
         39    >   FREE                                                     ~22
   25    40      > JMP                                                      ->25
         41    >   FE_FREE                                                  $21
   32    42    >   INIT_METHOD_CALL                                         !2, 'saveHtml'
         43        DO_FCALL                                      0  $28     
         44        ECHO                                                     $28
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.7 ms | 1392 KiB | 17 Q