3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_web_page( $url ) { $user_agent='Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0'; $options = array( CURLOPT_CUSTOMREQUEST =>"GET", //set request type post or get CURLOPT_POST =>false, //set to GET CURLOPT_USERAGENT => $user_agent, //set user agent CURLOPT_COOKIEFILE =>"cookie.txt", //set cookie file CURLOPT_COOKIEJAR =>"cookie.txt", //set cookie jar CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } $result = get_web_page( "www.kompas.com" ); if ( $result['errno'] != 0 ) { echo "error: bad url, timeout, redirect loop ..."; } if ( $result['http_code'] != 200 ) { echo "... error: no page, no permissions, no service ..."; } echo $page = $result['content']; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
Branch analysis from position: 8
filename:       /in/pdRdU
function name:  (null)
number of ops:  16
compiled vars:  !0 = $result, !1 = $page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   INIT_FCALL                                               'get_web_page'
          1        SEND_VAL                                                 'www.kompas.com'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   42     4        FETCH_DIM_R                                      ~4      !0, 'errno'
          5        IS_NOT_EQUAL                                             ~4, 0
          6      > JMPZ                                                     ~5, ->8
   44     7    >   ECHO                                                     'error%3A+bad+url%2C+timeout%2C+redirect+loop+...'
   47     8    >   FETCH_DIM_R                                      ~6      !0, 'http_code'
          9        IS_NOT_EQUAL                                             ~6, 200
         10      > JMPZ                                                     ~7, ->12
   49    11    >   ECHO                                                     '...+error%3A+no+page%2C+no+permissions%2C+no+service+...'
   51    12    >   FETCH_DIM_R                                      ~8      !0, 'content'
         13        ASSIGN                                           ~9      !1, ~8
         14        ECHO                                                     ~9
   54    15      > RETURN                                                   1

Function get_web_page:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pdRdU
function name:  get_web_page
number of ops:  64
compiled vars:  !0 = $url, !1 = $user_agent, !2 = $options, !3 = $ch, !4 = $content, !5 = $err, !6 = $errmsg, !7 = $header
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, 'Mozilla%2F5.0+%28Windows+NT+6.1%3B+rv%3A8.0%29+Gecko%2F20100101+Firefox%2F8.0'
   10     2        FETCH_CONSTANT                                   ~9      'CURLOPT_CUSTOMREQUEST'
          3        INIT_ARRAY                                       ~10     'GET', ~9
   11     4        FETCH_CONSTANT                                   ~11     'CURLOPT_POST'
   10     5        ADD_ARRAY_ELEMENT                                ~10     <false>, ~11
   12     6        FETCH_CONSTANT                                   ~12     'CURLOPT_USERAGENT'
          7        ADD_ARRAY_ELEMENT                                ~10     !1, ~12
   13     8        FETCH_CONSTANT                                   ~13     'CURLOPT_COOKIEFILE'
          9        ADD_ARRAY_ELEMENT                                ~10     'cookie.txt', ~13
   14    10        FETCH_CONSTANT                                   ~14     'CURLOPT_COOKIEJAR'
         11        ADD_ARRAY_ELEMENT                                ~10     'cookie.txt', ~14
   15    12        FETCH_CONSTANT                                   ~15     'CURLOPT_RETURNTRANSFER'
   10    13        ADD_ARRAY_ELEMENT                                ~10     <true>, ~15
   16    14        FETCH_CONSTANT                                   ~16     'CURLOPT_HEADER'
   10    15        ADD_ARRAY_ELEMENT                                ~10     <false>, ~16
   17    16        FETCH_CONSTANT                                   ~17     'CURLOPT_FOLLOWLOCATION'
   10    17        ADD_ARRAY_ELEMENT                                ~10     <true>, ~17
   18    18        FETCH_CONSTANT                                   ~18     'CURLOPT_ENCODING'
         19        ADD_ARRAY_ELEMENT                                ~10     '', ~18
   19    20        FETCH_CONSTANT                                   ~19     'CURLOPT_AUTOREFERER'
   10    21        ADD_ARRAY_ELEMENT                                ~10     <true>, ~19
   20    22        FETCH_CONSTANT                                   ~20     'CURLOPT_CONNECTTIMEOUT'
         23        ADD_ARRAY_ELEMENT                                ~10     120, ~20
   21    24        FETCH_CONSTANT                                   ~21     'CURLOPT_TIMEOUT'
         25        ADD_ARRAY_ELEMENT                                ~10     120, ~21
   22    26        FETCH_CONSTANT                                   ~22     'CURLOPT_MAXREDIRS'
         27        ADD_ARRAY_ELEMENT                                ~10     10, ~22
    8    28        ASSIGN                                                   !2, ~10
   25    29        INIT_FCALL_BY_NAME                                       'curl_init'
         30        SEND_VAR_EX                                              !0
         31        DO_FCALL                                      0  $24     
         32        ASSIGN                                                   !3, $24
   26    33        INIT_FCALL_BY_NAME                                       'curl_setopt_array'
         34        SEND_VAR_EX                                              !3
         35        SEND_VAR_EX                                              !2
         36        DO_FCALL                                      0          
   27    37        INIT_FCALL_BY_NAME                                       'curl_exec'
         38        SEND_VAR_EX                                              !3
         39        DO_FCALL                                      0  $27     
         40        ASSIGN                                                   !4, $27
   28    41        INIT_FCALL_BY_NAME                                       'curl_errno'
         42        SEND_VAR_EX                                              !3
         43        DO_FCALL                                      0  $29     
         44        ASSIGN                                                   !5, $29
   29    45        INIT_FCALL_BY_NAME                                       'curl_error'
         46        SEND_VAR_EX                                              !3
         47        DO_FCALL                                      0  $31     
         48        ASSIGN                                                   !6, $31
   30    49        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         50        SEND_VAR_EX                                              !3
         51        DO_FCALL                                      0  $33     
         52        ASSIGN                                                   !7, $33
   31    53        INIT_FCALL_BY_NAME                                       'curl_close'
         54        SEND_VAR_EX                                              !3
         55        DO_FCALL                                      0          
   33    56        ASSIGN_DIM                                               !7, 'errno'
         57        OP_DATA                                                  !5
   34    58        ASSIGN_DIM                                               !7, 'errmsg'
         59        OP_DATA                                                  !6
   35    60        ASSIGN_DIM                                               !7, 'content'
         61        OP_DATA                                                  !4
   36    62      > RETURN                                                   !7
   37    63*     > RETURN                                                   null

End of function get_web_page

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.95 ms | 1020 KiB | 14 Q