3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP error_reporting(); ini_set('display_errors', 'On'); function makeRequest($url, $requestBody) { $handle = curl_init(); $headers = array(); //array of request headers //Example headers for standart browser request //$headers = array( // 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($handle, CURLOPT_POST, 1); curl_setopt($handle, CURLOPT_POSTFIELDS, $requestBody); curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); curl_setopt($handle, CURLOPT_HEADER, 1); //This means include headers in response $result = curl_exec($handle); $header_size = curl_getinfo($handle, CURLINFO_HEADER_SIZE); $responseHeaders = substr($result, 0, $header_size); $responseBody = substr($result, $header_size, strlen($result) - $header_size); $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); if ($httpCode == 200) return $responseBody; else throw new Exception($responseBody); } $method = $_SERVER["REQUEST_METHOD"]; $request = array(); $request["a"] = "1"; $request["b"] = "3"; $request["c"] = "4"; $request["d"] = "7"; //$request = "a=1&b=3&c=4&d=7"; //This is the same with array version for standart post request. $response = makeRequest("http://httpbin.org/post", $request); echo $response; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IGveO
function name:  (null)
number of ops:  25
compiled vars:  !0 = $method, !1 = $request, !2 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        DO_ICALL                                                 
    3     2        INIT_FCALL                                               'ini_set'
          3        SEND_VAL                                                 'display_errors'
          4        SEND_VAL                                                 'On'
          5        DO_ICALL                                                 
   31     6        FETCH_R                      global              ~5      '_SERVER'
          7        FETCH_DIM_R                                      ~6      ~5, 'REQUEST_METHOD'
          8        ASSIGN                                                   !0, ~6
   34     9        ASSIGN                                                   !1, <array>
   35    10        ASSIGN_DIM                                               !1, 'a'
         11        OP_DATA                                                  '1'
   36    12        ASSIGN_DIM                                               !1, 'b'
         13        OP_DATA                                                  '3'
   37    14        ASSIGN_DIM                                               !1, 'c'
         15        OP_DATA                                                  '4'
   38    16        ASSIGN_DIM                                               !1, 'd'
         17        OP_DATA                                                  '7'
   40    18        INIT_FCALL                                               'makerequest'
         19        SEND_VAL                                                 'http%3A%2F%2Fhttpbin.org%2Fpost'
         20        SEND_VAR                                                 !1
         21        DO_FCALL                                      0  $13     
         22        ASSIGN                                                   !2, $13
   41    23        ECHO                                                     !2
   42    24      > RETURN                                                   1

Function makerequest:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 76
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/IGveO
function name:  makeRequest
number of ops:  81
compiled vars:  !0 = $url, !1 = $requestBody, !2 = $handle, !3 = $headers, !4 = $result, !5 = $header_size, !6 = $responseHeaders, !7 = $responseBody, !8 = $httpCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL_BY_NAME                                       'curl_init'
          3        DO_FCALL                                      0  $9      
          4        ASSIGN                                                   !2, $9
    8     5        ASSIGN                                                   !3, <array>
   13     6        INIT_FCALL_BY_NAME                                       'curl_setopt'
          7        SEND_VAR_EX                                              !2
          8        FETCH_CONSTANT                                   ~12     'CURLOPT_URL'
          9        SEND_VAL_EX                                              ~12
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   14    12        INIT_FCALL_BY_NAME                                       'curl_setopt'
         13        SEND_VAR_EX                                              !2
         14        FETCH_CONSTANT                                   ~14     'CURLOPT_RETURNTRANSFER'
         15        SEND_VAL_EX                                              ~14
         16        SEND_VAL_EX                                              1
         17        DO_FCALL                                      0          
   15    18        INIT_FCALL_BY_NAME                                       'curl_setopt'
         19        SEND_VAR_EX                                              !2
         20        FETCH_CONSTANT                                   ~16     'CURLOPT_POST'
         21        SEND_VAL_EX                                              ~16
         22        SEND_VAL_EX                                              1
         23        DO_FCALL                                      0          
   16    24        INIT_FCALL_BY_NAME                                       'curl_setopt'
         25        SEND_VAR_EX                                              !2
         26        FETCH_CONSTANT                                   ~18     'CURLOPT_POSTFIELDS'
         27        SEND_VAL_EX                                              ~18
         28        SEND_VAR_EX                                              !1
         29        DO_FCALL                                      0          
   17    30        INIT_FCALL_BY_NAME                                       'curl_setopt'
         31        SEND_VAR_EX                                              !2
         32        FETCH_CONSTANT                                   ~20     'CURLOPT_HTTPHEADER'
         33        SEND_VAL_EX                                              ~20
         34        SEND_VAR_EX                                              !3
         35        DO_FCALL                                      0          
   18    36        INIT_FCALL_BY_NAME                                       'curl_setopt'
         37        SEND_VAR_EX                                              !2
         38        FETCH_CONSTANT                                   ~22     'CURLOPT_HEADER'
         39        SEND_VAL_EX                                              ~22
         40        SEND_VAL_EX                                              1
         41        DO_FCALL                                      0          
   20    42        INIT_FCALL_BY_NAME                                       'curl_exec'
         43        SEND_VAR_EX                                              !2
         44        DO_FCALL                                      0  $24     
         45        ASSIGN                                                   !4, $24
   21    46        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         47        SEND_VAR_EX                                              !2
         48        FETCH_CONSTANT                                   ~26     'CURLINFO_HEADER_SIZE'
         49        SEND_VAL_EX                                              ~26
         50        DO_FCALL                                      0  $27     
         51        ASSIGN                                                   !5, $27
   22    52        INIT_FCALL                                               'substr'
         53        SEND_VAR                                                 !4
         54        SEND_VAL                                                 0
         55        SEND_VAR                                                 !5
         56        DO_ICALL                                         $29     
         57        ASSIGN                                                   !6, $29
   23    58        INIT_FCALL                                               'substr'
         59        SEND_VAR                                                 !4
         60        SEND_VAR                                                 !5
         61        STRLEN                                           ~31     !4
         62        SUB                                              ~32     ~31, !5
         63        SEND_VAL                                                 ~32
         64        DO_ICALL                                         $33     
         65        ASSIGN                                                   !7, $33
   24    66        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         67        SEND_VAR_EX                                              !2
         68        FETCH_CONSTANT                                   ~35     'CURLINFO_HTTP_CODE'
         69        SEND_VAL_EX                                              ~35
         70        DO_FCALL                                      0  $36     
         71        ASSIGN                                                   !8, $36
   25    72        IS_EQUAL                                                 !8, 200
         73      > JMPZ                                                     ~38, ->76
   26    74    > > RETURN                                                   !7
         75*       JMP                                                      ->80
   28    76    >   NEW                                              $39     'Exception'
         77        SEND_VAR_EX                                              !7
         78        DO_FCALL                                      0          
         79      > THROW                                         0          $39
   29    80*     > RETURN                                                   null

End of function makerequest

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.24 ms | 1398 KiB | 20 Q