3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Endpoint Open-Meteo per Grosseto $url = "https://api.open-meteo.com/v1/forecast?latitude=42.76&longitude=11.11&hourly=temperature_2m,relative_humidity_2m,weather_code&forecast_days=2&timezone=Europe/Rome"; // Impostazioni di contesto per timeout e User-Agent $options = [ "http" => [ "method" => "GET", "header" => "User-Agent: PHP-Student-Test\r\n", "timeout" => 5 ] ]; $context = stream_context_create($options); // Esecuzione della chiamata HTTP $response = @file_get_contents($url, false, $context); if ($response === FALSE) { die("Errore durante il recupero dei dati dall'API (verificare la connessione internet)."); } // Decodifica JSON $data = json_decode($response, true); if ($data === null) { die("Errore nella decodifica del JSON."); } // Funzione di supporto per i codici meteo WMO function decodificaMeteoCode(int $code): string { return match ($code) { 0 => "Cielo sereno ☀️", 1, 2, 3 => "Prevalentemente sereno / Nuvoloso ⛅", 45, 48 => "Nebbia 🌫️", 51, 53, 55 => "Pioggerella 🌧️", 61, 63, 65 => "Pioggia 🌧️", 71, 73, 75 => "Neve ❄️", 80, 81, 82 => "Rovesci di pioggia 🌦️", 95, 96, 99 => "Temporale 🌩️", default => "Codice sconosciuto ($code)" }; } // Estrazione array $orari = $data['hourly']['time']; $temperature = $data['hourly']['temperature_2m']; $umidita = $data['hourly']['relative_humidity_2m']; $codiciMeteo = $data['hourly']['weather_code']; // Output di test rapido (primi 5 orari) echo "=== TEST API OPEN-METEO (Grosseto) ===\n\n"; for ($i = 0; $i < 5; $i++) { $ora = date("d/m/Y H:i", strtotime($orari[$i])); $meteo = decodificaMeteoCode($codiciMeteo[$i]); echo "[$ora] Temp: {$temperature[$i]}°C | Umidità: {$umidita[$i]}% | Meteo: $meteo\n"; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 44
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 44
Branch analysis from position: 73
Branch analysis from position: 44
filename:       /in/YMRL4
function name:  (null)
number of ops:  74
compiled vars:  !0 = $url, !1 = $options, !2 = $context, !3 = $response, !4 = $data, !5 = $orari, !6 = $temperature, !7 = $umidita, !8 = $codiciMeteo, !9 = $i, !10 = $ora, !11 = $meteo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'https%3A%2F%2Fapi.open-meteo.com%2Fv1%2Fforecast%3Flatitude%3D42.76%26longitude%3D11.11%26hourly%3Dtemperature_2m%2Crelative_humidity_2m%2Cweather_code%26forecast_days%3D2%26timezone%3DEurope%2FRome'
    6     1        ASSIGN                                                       !1, <array>
   13     2        INIT_FCALL                                                   'stream_context_create'
          3        SEND_VAR                                                     !1
          4        DO_ICALL                                             $14     
          5        ASSIGN                                                       !2, $14
   16     6        BEGIN_SILENCE                                        ~16     
          7        INIT_FCALL                                                   'file_get_contents'
          8        SEND_VAR                                                     !0
          9        SEND_VAL                                                     <false>
         10        SEND_VAR                                                     !2
         11        DO_ICALL                                             $17     
         12        END_SILENCE                                                  ~16
         13        ASSIGN                                                       !3, $17
   18    14        TYPE_CHECK                                        4          !3
         15      > JMPZ                                                         ~19, ->19
   19    16    > > INIT_FCALL                                                   'exit'
         17*       SEND_VAL                                                     'Errore+durante+il+recupero+dei+dati+dall%27API+%28verificare+la+connessione+internet%29.'
         18*       DO_ICALL                                                     
   23    19    >   INIT_FCALL                                                   'json_decode'
         20        SEND_VAR                                                     !3
         21        SEND_VAL                                                     <true>
         22        DO_ICALL                                             $21     
         23        ASSIGN                                                       !4, $21
   25    24        TYPE_CHECK                                        2          !4
         25      > JMPZ                                                         ~23, ->29
   26    26    > > INIT_FCALL                                                   'exit'
         27*       SEND_VAL                                                     'Errore+nella+decodifica+del+JSON.'
         28*       DO_ICALL                                                     
   45    29    >   FETCH_DIM_R                                          ~25     !4, 'hourly'
         30        FETCH_DIM_R                                          ~26     ~25, 'time'
         31        ASSIGN                                                       !5, ~26
   46    32        FETCH_DIM_R                                          ~28     !4, 'hourly'
         33        FETCH_DIM_R                                          ~29     ~28, 'temperature_2m'
         34        ASSIGN                                                       !6, ~29
   47    35        FETCH_DIM_R                                          ~31     !4, 'hourly'
         36        FETCH_DIM_R                                          ~32     ~31, 'relative_humidity_2m'
         37        ASSIGN                                                       !7, ~32
   48    38        FETCH_DIM_R                                          ~34     !4, 'hourly'
         39        FETCH_DIM_R                                          ~35     ~34, 'weather_code'
         40        ASSIGN                                                       !8, ~35
   51    41        ECHO                                                         '%3D%3D%3D+TEST+API+OPEN-METEO+%28Grosseto%29+%3D%3D%3D%0A%0A'
   52    42        ASSIGN                                                       !9, 0
         43      > JMP                                                          ->71
   53    44    >   INIT_FCALL                                                   'date'
         45        SEND_VAL                                                     'd%2Fm%2FY+H%3Ai'
         46        INIT_FCALL                                                   'strtotime'
         47        FETCH_DIM_R                                          ~38     !5, !9
         48        SEND_VAL                                                     ~38
         49        DO_ICALL                                             $39     
         50        SEND_VAR                                                     $39
         51        DO_ICALL                                             $40     
         52        ASSIGN                                                       !10, $40
   54    53        INIT_FCALL                                                   'decodificameteocode'
         54        FETCH_DIM_R                                          ~42     !8, !9
         55        SEND_VAL                                                     ~42
         56        DO_FCALL                                          0  $43     
         57        ASSIGN                                                       !11, $43
   55    58        ROPE_INIT                                         9  ~48     '%5B'
         59        ROPE_ADD                                          1  ~48     ~48, !10
         60        ROPE_ADD                                          2  ~48     ~48, '%5D+Temp%3A+'
         61        FETCH_DIM_R                                          ~45     !6, !9
         62        ROPE_ADD                                          3  ~48     ~48, ~45
         63        ROPE_ADD                                          4  ~48     ~48, '%C2%B0C+%7C+Umidit%C3%A0%3A+'
         64        FETCH_DIM_R                                          ~46     !7, !9
         65        ROPE_ADD                                          5  ~48     ~48, ~46
         66        ROPE_ADD                                          6  ~48     ~48, '%25+%7C+Meteo%3A+'
         67        ROPE_ADD                                          7  ~48     ~48, !11
         68        ROPE_END                                          8  ~47     ~48, '%0A'
         69        ECHO                                                         ~47
   52    70        PRE_INC                                                      !9
         71    >   IS_SMALLER                                                   !9, 5
         72      > JMPNZ                                                        ~54, ->44
   57    73    > > RETURN                                                       1

Function decodificameteocode:
Finding entry points
Branch analysis from position: 0
22 jumps found. (Code = 195) Position 1 = 2, Position 2 = 4, Position 3 = 4, Position 4 = 4, Position 5 = 6, Position 6 = 6, Position 7 = 8, Position 8 = 8, Position 9 = 8, Position 10 = 10, Position 11 = 10, Position 12 = 10, Position 13 = 12, Position 14 = 12, Position 15 = 12, Position 16 = 14, Position 17 = 14, Position 18 = 14, Position 19 = 16, Position 20 = 16, Position 21 = 16, Position 22 = 18
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 4
Branch analysis from position: 4
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 6
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 8
Branch analysis from position: 8
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 10
Branch analysis from position: 10
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 12
Branch analysis from position: 12
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 14
Branch analysis from position: 14
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 16
Branch analysis from position: 16
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
filename:       /in/YMRL4
function name:  decodificaMeteoCode
number of ops:  27
compiled vars:  !0 = $code
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
   31     1      > MATCH                                                        !0, [ 0:->2, 1:->4, 2:->4, 3:->4, 45:->6, 48:->6, 51:->8, 53:->8, 55:->8, 61:->10, 63:->10, 65:->10, 71:->12, 73:->12, 75:->12, 80:->14, 81:->14, 82:->14, 95:->16, 96:->16, 99:->16, ], ->18
   32     2    >   QM_ASSIGN                                            ~2      'Cielo+sereno+%E2%98%80%EF%B8%8F'
          3      > JMP                                                          ->23
   33     4    >   QM_ASSIGN                                            ~2      'Prevalentemente+sereno+%2F+Nuvoloso+%E2%9B%85'
          5      > JMP                                                          ->23
   34     6    >   QM_ASSIGN                                            ~2      'Nebbia+%F0%9F%8C%AB%EF%B8%8F'
          7      > JMP                                                          ->23
   35     8    >   QM_ASSIGN                                            ~2      'Pioggerella+%F0%9F%8C%A7%EF%B8%8F'
          9      > JMP                                                          ->23
   36    10    >   QM_ASSIGN                                            ~2      'Pioggia+%F0%9F%8C%A7%EF%B8%8F'
         11      > JMP                                                          ->23
   37    12    >   QM_ASSIGN                                            ~2      'Neve+%E2%9D%84%EF%B8%8F'
         13      > JMP                                                          ->23
   38    14    >   QM_ASSIGN                                            ~2      'Rovesci+di+pioggia+%F0%9F%8C%A6%EF%B8%8F'
         15      > JMP                                                          ->23
   39    16    >   QM_ASSIGN                                            ~2      'Temporale+%F0%9F%8C%A9%EF%B8%8F'
         17      > JMP                                                          ->23
   40    18    >   ROPE_INIT                                         3  ~4      'Codice+sconosciuto+%28'
         19        ROPE_ADD                                          1  ~4      ~4, !0
         20        ROPE_END                                          2  ~3      ~4, '%29'
         21        QM_ASSIGN                                            ~2      ~3
         22      > JMP                                                          ->23
         23    >   VERIFY_RETURN_TYPE                                           ~2
         24      > RETURN                                                       ~2
   42    25*       VERIFY_RETURN_TYPE                                           
         26*     > RETURN                                                       null

End of function decodificameteocode

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
135.4 ms | 500 KiB | 14 Q