3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hhb_curl_init($custom_options_array = array()) { if(empty($custom_options_array)){ $custom_options_array=array(); //i feel kinda bad about this.. argv[1] of curl_init wants a string(url), or NULL //at least i want to allow NULL aswell :/ } if (!is_array($custom_options_array)) { throw new InvalidArgumentException('$custom_options_array must be an array!'); }; $options_array = array( CURLOPT_AUTOREFERER => true, CURLOPT_BINARYTRANSFER => true, CURLOPT_COOKIESESSION => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_FORBID_REUSE => false, CURLOPT_HTTPGET => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 11, //CURLOPT_REFERER=>'hanshenrik.tk', ); if (!array_key_exists(CURLOPT_COOKIEFILE, $custom_options_array)) { //do this only conditionally because tmpfile() call.. //we want PHP5.3- support -.- //for 5.4, just: $options_array[CURLOPT_COOKIEFILE]=stream_get_meta_data(tmpfile())['uri']; //static arr workaround for https://bugs.php.net/bug.php?id=66014 ... static $curl_cookiefile_filehandle_arr=array(); $curl_filehandle_arr[]=$options_array[CURLOPT_COOKIEFILE] = tmpfile(); $options_array[CURLOPT_COOKIEFILE] =stream_get_meta_data($options_array[CURLOPT_COOKIEFILE]); $options_array[CURLOPT_COOKIEFILE]=$options_array[CURLOPT_COOKIEFILE]['uri']; } //we can't use array_merge() because of how it handles integer-keys, it would/could cause corruption foreach($custom_options_array as $key => $val) { $options_array[$key] = $val; } unset($key, $val, $custom_options_array); $curl = curl_init(); curl_setopt_array($curl, $options_array); return $curl; } for($i=0;$i<9;++$i){ var_dump(hhb_curl_init()); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 2
Branch analysis from position: 10
Branch analysis from position: 2
filename:       /in/YE23c
function name:  (null)
number of ops:  11
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->8
   45     2    >   INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'hhb_curl_init'
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   44     7        PRE_INC                                                  !0
          8    >   IS_SMALLER                                               !0, 9
          9      > JMPNZ                                                    ~5, ->2
   46    10    > > RETURN                                                   1

Function hhb_curl_init:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 58
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 59, Position 2 = 64
Branch analysis from position: 59
2 jumps found. (Code = 78) Position 1 = 60, Position 2 = 64
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
Branch analysis from position: 58
Branch analysis from position: 4
filename:       /in/YE23c
function name:  hhb_curl_init
number of ops:  77
compiled vars:  !0 = $custom_options_array, !1 = $options_array, !2 = $curl_cookiefile_filehandle_arr, !3 = $curl_filehandle_arr, !4 = $val, !5 = $key, !6 = $curl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      <array>
    3     1        ISSET_ISEMPTY_CV                                         !0
          2      > JMPZ                                                     ~7, ->4
    4     3    >   ASSIGN                                                   !0, <array>
    8     4    >   TYPE_CHECK                                  128  ~9      !0
          5        BOOL_NOT                                         ~10     ~9
          6      > JMPZ                                                     ~10, ->11
    9     7    >   NEW                                              $11     'InvalidArgumentException'
          8        SEND_VAL_EX                                              '%24custom_options_array+must+be+an+array%21'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $11
   12    11    >   FETCH_CONSTANT                                   ~13     'CURLOPT_AUTOREFERER'
         12        INIT_ARRAY                                       ~14     <true>, ~13
   13    13        FETCH_CONSTANT                                   ~15     'CURLOPT_BINARYTRANSFER'
   12    14        ADD_ARRAY_ELEMENT                                ~14     <true>, ~15
   14    15        FETCH_CONSTANT                                   ~16     'CURLOPT_COOKIESESSION'
   12    16        ADD_ARRAY_ELEMENT                                ~14     <true>, ~16
   15    17        FETCH_CONSTANT                                   ~17     'CURLOPT_FOLLOWLOCATION'
   12    18        ADD_ARRAY_ELEMENT                                ~14     <true>, ~17
   16    19        FETCH_CONSTANT                                   ~18     'CURLOPT_FORBID_REUSE'
   12    20        ADD_ARRAY_ELEMENT                                ~14     <false>, ~18
   17    21        FETCH_CONSTANT                                   ~19     'CURLOPT_HTTPGET'
   12    22        ADD_ARRAY_ELEMENT                                ~14     <true>, ~19
   18    23        FETCH_CONSTANT                                   ~20     'CURLOPT_RETURNTRANSFER'
   12    24        ADD_ARRAY_ELEMENT                                ~14     <true>, ~20
   19    25        FETCH_CONSTANT                                   ~21     'CURLOPT_SSL_VERIFYPEER'
   12    26        ADD_ARRAY_ELEMENT                                ~14     <false>, ~21
   20    27        FETCH_CONSTANT                                   ~22     'CURLOPT_CONNECTTIMEOUT'
         28        ADD_ARRAY_ELEMENT                                ~14     10, ~22
   21    29        FETCH_CONSTANT                                   ~23     'CURLOPT_TIMEOUT'
         30        ADD_ARRAY_ELEMENT                                ~14     11, ~23
   11    31        ASSIGN                                                   !1, ~14
   24    32        FETCH_CONSTANT                                   ~25     'CURLOPT_COOKIEFILE'
         33        ARRAY_KEY_EXISTS                                 ~26     ~25, !0
         34        BOOL_NOT                                         ~27     ~26
         35      > JMPZ                                                     ~27, ->58
   29    36    >   BIND_STATIC                                              !2
   30    37        FETCH_CONSTANT                                   ~29     'CURLOPT_COOKIEFILE'
         38        INIT_FCALL                                               'tmpfile'
         39        DO_ICALL                                         $31     
         40        ASSIGN_DIM                                       ~30     !1, ~29
         41        OP_DATA                                                  $31
         42        ASSIGN_DIM                                               !3
         43        OP_DATA                                                  ~30
   31    44        FETCH_CONSTANT                                   ~32     'CURLOPT_COOKIEFILE'
         45        INIT_FCALL                                               'stream_get_meta_data'
         46        FETCH_CONSTANT                                   ~34     'CURLOPT_COOKIEFILE'
         47        FETCH_DIM_R                                      ~35     !1, ~34
         48        SEND_VAL                                                 ~35
         49        DO_ICALL                                         $36     
         50        ASSIGN_DIM                                               !1, ~32
         51        OP_DATA                                                  $36
   32    52        FETCH_CONSTANT                                   ~37     'CURLOPT_COOKIEFILE'
         53        FETCH_CONSTANT                                   ~39     'CURLOPT_COOKIEFILE'
         54        FETCH_DIM_R                                      ~40     !1, ~39
         55        FETCH_DIM_R                                      ~41     ~40, 'uri'
         56        ASSIGN_DIM                                               !1, ~37
         57        OP_DATA                                                  ~41
   36    58    > > FE_RESET_R                                       $42     !0, ->64
         59    > > FE_FETCH_R                                       ~43     $42, !4, ->64
         60    >   ASSIGN                                                   !5, ~43
   37    61        ASSIGN_DIM                                               !1, !5
         62        OP_DATA                                                  !4
   36    63      > JMP                                                      ->59
         64    >   FE_FREE                                                  $42
   39    65        UNSET_CV                                                 !5
         66        UNSET_CV                                                 !4
         67        UNSET_CV                                                 !0
   40    68        INIT_FCALL_BY_NAME                                       'curl_init'
         69        DO_FCALL                                      0  $46     
         70        ASSIGN                                                   !6, $46
   41    71        INIT_FCALL_BY_NAME                                       'curl_setopt_array'
         72        SEND_VAR_EX                                              !6
         73        SEND_VAR_EX                                              !1
         74        DO_FCALL                                      0          
   42    75      > RETURN                                                   !6
   43    76*     > RETURN                                                   null

End of function hhb_curl_init

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.79 ms | 1407 KiB | 20 Q