3v4l.org

run code in 300+ PHP versions simultaneously
<?php $i=1; while ($i<=5) { # code... $url = 'http://www.amazon.in/gp/bestsellers/electronics/ref=zg_bs_nav_0#'.$i; echo $url; $html= file_get_contents($url); $dom = new DOMDocument(); @$dom->loadHTML($html); $xPath = new DOMXPath($dom); $classname="zg_title"; $elements = $xPath->query("//*[contains(@class, '$classname')]"); foreach ($elements as $e) { $lnk = $e->getAttribute('href'); $e->setAttribute("href", "http://www.amazon.in".$lnk); $newdoc = new DOMDocument; $e = $newdoc->importNode($e, true); $newdoc->appendChild($e); $html = $newdoc->saveHTML(); echo $html; } $i++; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 2
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 56
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 56
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 2
Branch analysis from position: 60
Branch analysis from position: 2
Branch analysis from position: 56
filename:       /in/JH6Gk
function name:  (null)
number of ops:  61
compiled vars:  !0 = $i, !1 = $url, !2 = $html, !3 = $dom, !4 = $xPath, !5 = $classname, !6 = $elements, !7 = $e, !8 = $lnk, !9 = $newdoc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1
    4     1      > JMP                                                      ->58
    7     2    >   CONCAT                                           ~11     'http%3A%2F%2Fwww.amazon.in%2Fgp%2Fbestsellers%2Felectronics%2Fref%3Dzg_bs_nav_0%23', !0
          3        ASSIGN                                                   !1, ~11
    8     4        ECHO                                                     !1
    9     5        INIT_FCALL                                               'file_get_contents'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $13     
          8        ASSIGN                                                   !2, $13
   10     9        NEW                                              $15     'DOMDocument'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $15
   11    12        BEGIN_SILENCE                                    ~18     
         13        INIT_METHOD_CALL                                         !3, 'loadHTML'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0          
         16        END_SILENCE                                              ~18
   12    17        NEW                                              $20     'DOMXPath'
         18        SEND_VAR_EX                                              !3
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !4, $20
   13    21        ASSIGN                                                   !5, 'zg_title'
   14    22        INIT_METHOD_CALL                                         !4, 'query'
         23        ROPE_INIT                                     3  ~25     '%2F%2F%2A%5Bcontains%28%40class%2C+%27'
         24        ROPE_ADD                                      1  ~25     ~25, !5
         25        ROPE_END                                      2  ~24     ~25, '%27%29%5D'
         26        SEND_VAL_EX                                              ~24
         27        DO_FCALL                                      0  $27     
         28        ASSIGN                                                   !6, $27
   15    29      > FE_RESET_R                                       $29     !6, ->56
         30    > > FE_FETCH_R                                               $29, !7, ->56
   17    31    >   INIT_METHOD_CALL                                         !7, 'getAttribute'
         32        SEND_VAL_EX                                              'href'
         33        DO_FCALL                                      0  $30     
         34        ASSIGN                                                   !8, $30
   18    35        INIT_METHOD_CALL                                         !7, 'setAttribute'
         36        SEND_VAL_EX                                              'href'
         37        CONCAT                                           ~32     'http%3A%2F%2Fwww.amazon.in', !8
         38        SEND_VAL_EX                                              ~32
         39        DO_FCALL                                      0          
   19    40        NEW                                              $34     'DOMDocument'
         41        DO_FCALL                                      0          
         42        ASSIGN                                                   !9, $34
   20    43        INIT_METHOD_CALL                                         !9, 'importNode'
         44        SEND_VAR_EX                                              !7
         45        SEND_VAL_EX                                              <true>
         46        DO_FCALL                                      0  $37     
         47        ASSIGN                                                   !7, $37
   21    48        INIT_METHOD_CALL                                         !9, 'appendChild'
         49        SEND_VAR_EX                                              !7
         50        DO_FCALL                                      0          
   22    51        INIT_METHOD_CALL                                         !9, 'saveHTML'
         52        DO_FCALL                                      0  $40     
         53        ASSIGN                                                   !2, $40
   23    54        ECHO                                                     !2
   15    55      > JMP                                                      ->30
         56    >   FE_FREE                                                  $29
   25    57        PRE_INC                                                  !0
    4    58    >   IS_SMALLER_OR_EQUAL                                      !0, 5
         59      > JMPNZ                                                    ~43, ->2
   27    60    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.14 ms | 1400 KiB | 15 Q