3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fetch_fb_fans($id, $no_of_retries = 10, $pause = 500000 /* 500ms */){ $ret = array(); $matches = array(); $url = 'http://www.facebook.com/plugins/fan.php?connections=100&id=' . $id; $context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'))); for($a = 0; $a < $no_of_retries; $a++){ $like_html = file_get_contents($url, false, $context); preg_match_all('{href="https?://www\.facebook\.com/([a-zA-Z0-9._-]+)" data-jsid="anchor" target="_blank"}', $like_html, $matches); if(empty($matches[1])){ // failed to fetch any fans - convert returning array, cause it might be not empty return array_keys($ret); }else{ // merge profiles as array keys so they will stay unique $ret = array_merge($ret, array_flip($matches[1])); } // don't get banned as flooder usleep($pause); } return array_keys($ret); } print_r(fetch_fb_fans('527201224055828', 2, 400000));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1iiBg
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'fetch_fb_fans'
          2        SEND_VAL                                                 '527201224055828'
          3        SEND_VAL                                                 2
          4        SEND_VAL                                                 400000
          5        DO_FCALL                                      0  $0      
          6        SEND_VAR                                                 $0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function fetch_fb_fans:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 13
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 13
Branch analysis from position: 46
Branch analysis from position: 13
filename:       /in/1iiBg
function name:  fetch_fb_fans
number of ops:  51
compiled vars:  !0 = $id, !1 = $no_of_retries, !2 = $pause, !3 = $ret, !4 = $matches, !5 = $url, !6 = $context, !7 = $a, !8 = $like_html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      10
          2        RECV_INIT                                        !2      500000
    4     3        ASSIGN                                                   !3, <array>
    6     4        ASSIGN                                                   !4, <array>
    7     5        CONCAT                                           ~11     'http%3A%2F%2Fwww.facebook.com%2Fplugins%2Ffan.php%3Fconnections%3D100%26id%3D', !0
          6        ASSIGN                                                   !5, ~11
    8     7        INIT_FCALL                                               'stream_context_create'
          8        SEND_VAL                                                 <array>
          9        DO_ICALL                                         $13     
         10        ASSIGN                                                   !6, $13
    9    11        ASSIGN                                                   !7, 0
         12      > JMP                                                      ->44
   10    13    >   INIT_FCALL                                               'file_get_contents'
         14        SEND_VAR                                                 !5
         15        SEND_VAL                                                 <false>
         16        SEND_VAR                                                 !6
         17        DO_ICALL                                         $16     
         18        ASSIGN                                                   !8, $16
   11    19        INIT_FCALL                                               'preg_match_all'
         20        SEND_VAL                                                 '%7Bhref%3D%22https%3F%3A%2F%2Fwww%5C.facebook%5C.com%2F%28%5Ba-zA-Z0-9._-%5D%2B%29%22+data-jsid%3D%22anchor%22+target%3D%22_blank%22%7D'
         21        SEND_VAR                                                 !8
         22        SEND_REF                                                 !4
         23        DO_ICALL                                                 
   12    24        ISSET_ISEMPTY_DIM_OBJ                         1          !4, 1
         25      > JMPZ                                                     ~19, ->31
   14    26    >   INIT_FCALL                                               'array_keys'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                         $20     
         29      > RETURN                                                   $20
         30*       JMP                                                      ->40
   17    31    >   INIT_FCALL                                               'array_merge'
         32        SEND_VAR                                                 !3
         33        INIT_FCALL                                               'array_flip'
         34        FETCH_DIM_R                                      ~21     !4, 1
         35        SEND_VAL                                                 ~21
         36        DO_ICALL                                         $22     
         37        SEND_VAR                                                 $22
         38        DO_ICALL                                         $23     
         39        ASSIGN                                                   !3, $23
   20    40        INIT_FCALL                                               'usleep'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                                 
    9    43        PRE_INC                                                  !7
         44    >   IS_SMALLER                                               !7, !1
         45      > JMPNZ                                                    ~27, ->13
   22    46    >   INIT_FCALL                                               'array_keys'
         47        SEND_VAR                                                 !3
         48        DO_ICALL                                         $28     
         49      > RETURN                                                   $28
   23    50*     > RETURN                                                   null

End of function fetch_fb_fans

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.04 ms | 1403 KiB | 30 Q