3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jobTemplateDetails = '<a href="https://www2.google.com">Click!</a> <a href="https://www3.google.com">Click!</a>'; ////////////////////// CHANGE ALL LINKS $linkDom = new DOMDocument; $linkDom->loadHTML($jobTemplateDetails); $allLinks = $linkDom->getElementsByTagName('a'); foreach ($allLinks as $rawLink) { $longLink = $rawLink->getAttribute('href'); $str = 'abcdefghijklmnopqrstuvwxyz'; $randomChar1 = $str[mt_rand(0, strlen($str)-1)]; $randomChar2 = $str[mt_rand(0, strlen($str)-1)]; $randomChar3 = $str[mt_rand(0, strlen($str)-1)]; $randomChar4 = $str[mt_rand(0, strlen($str)-1)]; $shortURL = mt_rand(1, 9).$randomChar1.mt_rand(1, 9).$randomChar2.$randomChar3.$randomChar4; $rawLink->setAttribute('href', $shortURL); } echo $linkDom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 69
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 69
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
filename:       /in/KuCic
function name:  (null)
number of ops:  74
compiled vars:  !0 = $jobTemplateDetails, !1 = $linkDom, !2 = $allLinks, !3 = $rawLink, !4 = $longLink, !5 = $str, !6 = $randomChar1, !7 = $randomChar2, !8 = $randomChar3, !9 = $randomChar4, !10 = $shortURL
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, '%3Ca+href%3D%22https%3A%2F%2Fwww2.google.com%22%3EClick%21%3C%2Fa%3E%0A%3Ca+href%3D%22https%3A%2F%2Fwww3.google.com%22%3EClick%21%3C%2Fa%3E'
    9     1        NEW                                              $12     'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $12
   11     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   13     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'a'
          9        DO_FCALL                                      0  $16     
         10        ASSIGN                                                   !2, $16
   15    11      > FE_RESET_R                                       $18     !2, ->69
         12    > > FE_FETCH_R                                               $18, !3, ->69
   17    13    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         14        SEND_VAL_EX                                              'href'
         15        DO_FCALL                                      0  $19     
         16        ASSIGN                                                   !4, $19
   18    17        ASSIGN                                                   !5, 'abcdefghijklmnopqrstuvwxyz'
   19    18        INIT_FCALL                                               'mt_rand'
         19        SEND_VAL                                                 0
         20        STRLEN                                           ~22     !5
         21        SUB                                              ~23     ~22, 1
         22        SEND_VAL                                                 ~23
         23        DO_ICALL                                         $24     
         24        FETCH_DIM_R                                      ~25     !5, $24
         25        ASSIGN                                                   !6, ~25
   20    26        INIT_FCALL                                               'mt_rand'
         27        SEND_VAL                                                 0
         28        STRLEN                                           ~27     !5
         29        SUB                                              ~28     ~27, 1
         30        SEND_VAL                                                 ~28
         31        DO_ICALL                                         $29     
         32        FETCH_DIM_R                                      ~30     !5, $29
         33        ASSIGN                                                   !7, ~30
   21    34        INIT_FCALL                                               'mt_rand'
         35        SEND_VAL                                                 0
         36        STRLEN                                           ~32     !5
         37        SUB                                              ~33     ~32, 1
         38        SEND_VAL                                                 ~33
         39        DO_ICALL                                         $34     
         40        FETCH_DIM_R                                      ~35     !5, $34
         41        ASSIGN                                                   !8, ~35
   22    42        INIT_FCALL                                               'mt_rand'
         43        SEND_VAL                                                 0
         44        STRLEN                                           ~37     !5
         45        SUB                                              ~38     ~37, 1
         46        SEND_VAL                                                 ~38
         47        DO_ICALL                                         $39     
         48        FETCH_DIM_R                                      ~40     !5, $39
         49        ASSIGN                                                   !9, ~40
   23    50        INIT_FCALL                                               'mt_rand'
         51        SEND_VAL                                                 1
         52        SEND_VAL                                                 9
         53        DO_ICALL                                         $42     
         54        CONCAT                                           ~43     $42, !6
         55        INIT_FCALL                                               'mt_rand'
         56        SEND_VAL                                                 1
         57        SEND_VAL                                                 9
         58        DO_ICALL                                         $44     
         59        CONCAT                                           ~45     ~43, $44
         60        CONCAT                                           ~46     ~45, !7
         61        CONCAT                                           ~47     ~46, !8
         62        CONCAT                                           ~48     ~47, !9
         63        ASSIGN                                                   !10, ~48
   24    64        INIT_METHOD_CALL                                         !3, 'setAttribute'
         65        SEND_VAL_EX                                              'href'
         66        SEND_VAR_EX                                              !10
         67        DO_FCALL                                      0          
   15    68      > JMP                                                      ->12
         69    >   FE_FREE                                                  $18
   26    70        INIT_METHOD_CALL                                         !1, 'saveHTML'
         71        DO_FCALL                                      0  $51     
         72        ECHO                                                     $51
         73      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.5 ms | 1005 KiB | 14 Q