3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRemoteFile($url) { // get the host name and url path $parsedUrl = parse_url($url); $host = $parsedUrl['host']; if (isset($parsedUrl['path'])) { $path = $parsedUrl['path']; } else { // the url is pointing to the host like http://www.mysite.com $path = '/'; } if (isset($parsedUrl['query'])) { $path .= '?' . $parsedUrl['query']; } if (isset($parsedUrl['port'])) { $port = $parsedUrl['port']; } else { // most sites use port 80 $port = '80'; } $timeout = 10; $response = ''; // connect to the remote server $fp = @fsockopen($host, '80', $errno, $errstr, $timeout ); if( !$fp ) { echo "Cannot retrieve $url"; } else { // send the necessary headers to get the file fputs($fp, "GET $path HTTP/1.0\r\n" . "Host: $host\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3\r\n" . "Accept: */*\r\n" . "Accept-Language: en-us,en;q=0.5\r\n" . "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" . "Keep-Alive: 300\r\n" . "Connection: keep-alive\r\n" . "Referer: http://$host\r\n\r\n"); // retrieve the response from the remote server while ( $line = fread( $fp, 4096 ) ) { $response .= $line; } fclose( $fp ); // strip the headers $pos = strpos($response, "\r\n\r\n"); $response = substr($response, $pos + 4); } // return the file content return $response; } $content = getRemoteFile('http://www.gammebaie.com/feed?post_type=actualites'); var_dump($content);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UqFUG
function name:  (null)
number of ops:  8
compiled vars:  !0 = $content
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   INIT_FCALL                                               'getremotefile'
          1        SEND_VAL                                                 'http%3A%2F%2Fwww.gammebaie.com%2Ffeed%3Fpost_type%3Dactualites'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   61     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function getremotefile:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 64
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 64
Branch analysis from position: 71
Branch analysis from position: 64
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
Branch analysis from position: 42
Branch analysis from position: 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
Branch analysis from position: 18
filename:       /in/UqFUG
function name:  getRemoteFile
number of ops:  87
compiled vars:  !0 = $url, !1 = $parsedUrl, !2 = $host, !3 = $path, !4 = $port, !5 = $timeout, !6 = $response, !7 = $fp, !8 = $errno, !9 = $errstr, !10 = $line, !11 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'parse_url'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $12     
          4        ASSIGN                                                   !1, $12
    7     5        FETCH_DIM_R                                      ~14     !1, 'host'
          6        ASSIGN                                                   !2, ~14
    8     7        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'path'
          8      > JMPZ                                                     ~16, ->12
    9     9    >   FETCH_DIM_R                                      ~17     !1, 'path'
         10        ASSIGN                                                   !3, ~17
         11      > JMP                                                      ->13
   12    12    >   ASSIGN                                                   !3, '%2F'
   15    13    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'query'
         14      > JMPZ                                                     ~20, ->18
   16    15    >   FETCH_DIM_R                                      ~21     !1, 'query'
         16        CONCAT                                           ~22     '%3F', ~21
         17        ASSIGN_OP                                     8          !3, ~22
   19    18    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'port'
         19      > JMPZ                                                     ~24, ->23
   20    20    >   FETCH_DIM_R                                      ~25     !1, 'port'
         21        ASSIGN                                                   !4, ~25
         22      > JMP                                                      ->24
   23    23    >   ASSIGN                                                   !4, '80'
   26    24    >   ASSIGN                                                   !5, 10
   27    25        ASSIGN                                                   !6, ''
   29    26        BEGIN_SILENCE                                    ~30     
         27        INIT_FCALL                                               'fsockopen'
         28        SEND_VAR                                                 !2
         29        SEND_VAL                                                 '80'
         30        SEND_REF                                                 !8
         31        SEND_REF                                                 !9
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                         $31     
         34        END_SILENCE                                              ~30
         35        ASSIGN                                                   !7, $31
   31    36        BOOL_NOT                                         ~33     !7
         37      > JMPZ                                                     ~33, ->42
   32    38    >   NOP                                                      
         39        FAST_CONCAT                                      ~34     'Cannot+retrieve+', !0
         40        ECHO                                                     ~34
         41      > JMP                                                      ->85
   35    42    >   INIT_FCALL                                               'fputs'
         43        SEND_VAR                                                 !7
         44        ROPE_INIT                                     3  ~36     'GET+'
         45        ROPE_ADD                                      1  ~36     ~36, !3
         46        ROPE_END                                      2  ~35     ~36, '+HTTP%2F1.0%0D%0A'
   36    47        ROPE_INIT                                     3  ~39     'Host%3A+'
         48        ROPE_ADD                                      1  ~39     ~39, !2
         49        ROPE_END                                      2  ~38     ~39, '%0D%0A'
         50        CONCAT                                           ~41     ~35, ~38
   37    51        CONCAT                                           ~42     ~41, 'User-Agent%3A+Mozilla%2F5.0+%28Windows%3B+U%3B+Windows+NT+5.1%3B+en-US%3B+rv%3A1.8.0.3%29+Gecko%2F20060426+Firefox%2F1.5.0.3%0D%0A'
   38    52        CONCAT                                           ~43     ~42, 'Accept%3A+%2A%2F%2A%0D%0A'
   39    53        CONCAT                                           ~44     ~43, 'Accept-Language%3A+en-us%2Cen%3Bq%3D0.5%0D%0A'
   40    54        CONCAT                                           ~45     ~44, 'Accept-Charset%3A+ISO-8859-1%2Cutf-8%3Bq%3D0.7%2C%2A%3Bq%3D0.7%0D%0A'
   41    55        CONCAT                                           ~46     ~45, 'Keep-Alive%3A+300%0D%0A'
   42    56        CONCAT                                           ~47     ~46, 'Connection%3A+keep-alive%0D%0A'
   43    57        ROPE_INIT                                     3  ~49     'Referer%3A+http%3A%2F%2F'
         58        ROPE_ADD                                      1  ~49     ~49, !2
         59        ROPE_END                                      2  ~48     ~49, '%0D%0A%0D%0A'
         60        CONCAT                                           ~51     ~47, ~48
         61        SEND_VAL                                                 ~51
         62        DO_ICALL                                                 
   46    63      > JMP                                                      ->65
   47    64    >   ASSIGN_OP                                     8          !6, !10
   46    65    >   INIT_FCALL                                               'fread'
         66        SEND_VAR                                                 !7
         67        SEND_VAL                                                 4096
         68        DO_ICALL                                         $54     
         69        ASSIGN                                           ~55     !10, $54
         70      > JMPNZ                                                    ~55, ->64
   50    71    >   INIT_FCALL                                               'fclose'
         72        SEND_VAR                                                 !7
         73        DO_ICALL                                                 
   53    74        INIT_FCALL                                               'strpos'
         75        SEND_VAR                                                 !6
         76        SEND_VAL                                                 '%0D%0A%0D%0A'
         77        DO_ICALL                                         $57     
         78        ASSIGN                                                   !11, $57
   54    79        INIT_FCALL                                               'substr'
         80        SEND_VAR                                                 !6
         81        ADD                                              ~59     !11, 4
         82        SEND_VAL                                                 ~59
         83        DO_ICALL                                         $60     
         84        ASSIGN                                                   !6, $60
   58    85    > > RETURN                                                   !6
   59    86*     > RETURN                                                   null

End of function getremotefile

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.46 ms | 1407 KiB | 30 Q