3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'https://www.tiny.com.br/api2/produtos.pesquisa.php'; $token = 'coloque aqui a sua chave da api'; $pesquisa = 'xxxxx'; $data = "token=$token&pesquisa=$pesquisa&formato=XML"; enviarREST($url, $data); function enviarREST($url, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => $data )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problema com $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problema obtendo retorno de $url, $php_errormsg"); } return $response; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3q7DL
function name:  (null)
number of ops:  14
compiled vars:  !0 = $url, !1 = $token, !2 = $pesquisa, !3 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'https%3A%2F%2Fwww.tiny.com.br%2Fapi2%2Fprodutos.pesquisa.php'
    4     1        ASSIGN                                                   !1, 'coloque+aqui+a+sua+chave+da+api'
    5     2        ASSIGN                                                   !2, 'xxxxx'
    6     3        ROPE_INIT                                     5  ~8      'token%3D'
          4        ROPE_ADD                                      1  ~8      ~8, !1
          5        ROPE_ADD                                      2  ~8      ~8, '%26pesquisa%3D'
          6        ROPE_ADD                                      3  ~8      ~8, !2
          7        ROPE_END                                      4  ~7      ~8, '%26formato%3DXML'
          8        ASSIGN                                                   !3, ~7
    8     9        INIT_FCALL_BY_NAME                                       'enviarREST'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAR_EX                                              !3
         12        DO_FCALL                                      0          
   31    13      > RETURN                                                   1

Function enviarrest:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 35
Branch analysis from position: 27
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 51
Branch analysis from position: 43
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/3q7DL
function name:  enviarREST
number of ops:  53
compiled vars:  !0 = $url, !1 = $data, !2 = $optional_headers, !3 = $params, !4 = $ctx, !5 = $fp, !6 = $php_errormsg, !7 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   12     3        INIT_ARRAY                                       ~8      'POST', 'method'
   13     4        ADD_ARRAY_ELEMENT                                ~8      !1, 'content'
          5        INIT_ARRAY                                       ~9      ~8, 'http'
   11     6        ASSIGN                                                   !3, ~9
   16     7        TYPE_CHECK                                  1020          !2
          8      > JMPZ                                                     ~11, ->12
   17     9    >   FETCH_DIM_W                                      $12     !3, 'http'
         10        ASSIGN_DIM                                               $12, 'header'
         11        OP_DATA                                                  !2
   20    12    >   INIT_FCALL                                               'stream_context_create'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !4, $14
   21    16        BEGIN_SILENCE                                    ~16     
         17        INIT_FCALL                                               'fopen'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 'rb'
         20        SEND_VAL                                                 <false>
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                         $17     
         23        END_SILENCE                                              ~16
         24        ASSIGN                                                   !5, $17
   22    25        BOOL_NOT                                         ~19     !5
         26      > JMPZ                                                     ~19, ->35
   23    27    >   NEW                                              $20     'Exception'
         28        ROPE_INIT                                     4  ~22     'Problema+com+'
         29        ROPE_ADD                                      1  ~22     ~22, !0
         30        ROPE_ADD                                      2  ~22     ~22, '%2C+'
         31        ROPE_END                                      3  ~21     ~22, !6
         32        SEND_VAL_EX                                              ~21
         33        DO_FCALL                                      0          
         34      > THROW                                         0          $20
   25    35    >   BEGIN_SILENCE                                    ~25     
         36        INIT_FCALL                                               'stream_get_contents'
         37        SEND_VAR                                                 !5
         38        DO_ICALL                                         $26     
         39        END_SILENCE                                              ~25
         40        ASSIGN                                                   !7, $26
   26    41        TYPE_CHECK                                    4          !7
         42      > JMPZ                                                     ~28, ->51
   27    43    >   NEW                                              $29     'Exception'
         44        ROPE_INIT                                     4  ~31     'Problema+obtendo+retorno+de+'
         45        ROPE_ADD                                      1  ~31     ~31, !0
         46        ROPE_ADD                                      2  ~31     ~31, '%2C+'
         47        ROPE_END                                      3  ~30     ~31, !6
         48        SEND_VAL_EX                                              ~30
         49        DO_FCALL                                      0          
         50      > THROW                                         0          $29
   30    51    > > RETURN                                                   !7
   31    52*     > RETURN                                                   null

End of function enviarrest

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.77 ms | 1400 KiB | 19 Q