3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Endpoint Open-Meteo per Grosseto (2 giorni di previsione oraria) $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"; // 1. Inizializzazione cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlError = curl_error($ch); curl_close($ch); // 2. Controllo errori di connessione if ($response === false) { die("Errore nella chiamata cURL: " . $curlError); } if ($httpCode !== 200) { die("L'API ha risposto con codice HTTP: " . $httpCode); } // 3. Decodifica JSON $data = json_decode($response, true); if ($data === null) { die("Errore nella decodifica del JSON."); } // Funzione di supporto per tradurre i codici WMO dell'API 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 degli array orari $orari = $data['hourly']['time']; $temperature = $data['hourly']['temperature_2m']; $umidita = $data['hourly']['relative_humidity_2m']; $codiciMeteo = $data['hourly']['weather_code']; ?> <!DOCTYPE html> <html lang="it"> <head> <meta charset="UTF-8"> <title>Test API Open-Meteo</title> <style> body { font-family: Arial, sans-serif; margin: 20px; background-color: #f4f4f9; } table { border-collapse: collapse; width: 100%; max-width: 800px; background: #fff; } th, td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; } th { background-color: #007bff; color: white; } tr:nth-child(even) { background-color: #f9f9f9; } </style> </head> <body> <h2>Previsioni Orarie Grosseto (48 ore)</h2> <p><strong>Unità di misura:</strong> Temperatura (°C), Umidità (%)</p> <table> <thead> <tr> <th>Data e Ora</th> <th>Meteo</th> <th>Temperatura (°C)</th> <th>Umidità (%)</th> </tr> </thead> <tbody> <?php // Ciclo sugli array paralleli restituite dall'API $totaleOre = count($orari); for ($i = 0; $i < $totaleOre; $i++): // Formattazione data/ora per renderla più leggibile (da YYYY-MM-DDTHH:mm a DD/MM/YYYY HH:mm) $dataFormattata = date("d/m/Y H:i", strtotime($orari[$i])); ?> <tr> <td><?= $dataFormattata ?></td> <td><?= decodificaMeteoCode($codiciMeteo[$i]) ?></td> <td><?= $temperature[$i] ?> °C</td> <td><?= $umidita[$i] ?> %</td> </tr> <?php endfor; ?> </tbody> </table> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 51
Branch analysis from position: 47
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 61
Branch analysis from position: 58
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
2 jumps found. (Code = 44) Position 1 = 105, Position 2 = 78
Branch analysis from position: 105
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 105, Position 2 = 78
Branch analysis from position: 105
Branch analysis from position: 78
filename:       /in/QCcOM
function name:  (null)
number of ops:  107
compiled vars:  !0 = $url, !1 = $ch, !2 = $response, !3 = $httpCode, !4 = $curlError, !5 = $data, !6 = $orari, !7 = $temperature, !8 = $umidita, !9 = $codiciMeteo, !10 = $totaleOre, !11 = $i, !12 = $dataFormattata
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        INIT_FCALL_BY_NAME                                           'curl_init'
          2        DO_FCALL                                          0  $14     
          3        ASSIGN                                                       !1, $14
    7     4        INIT_FCALL_BY_NAME                                           'curl_setopt'
          5        SEND_VAR_EX                                                  !1
          6        FETCH_CONSTANT                                       ~16     'CURLOPT_URL'
          7        SEND_VAL_EX                                                  ~16
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0          
    8    10        INIT_FCALL_BY_NAME                                           'curl_setopt'
         11        SEND_VAR_EX                                                  !1
         12        FETCH_CONSTANT                                       ~18     'CURLOPT_RETURNTRANSFER'
         13        SEND_VAL_EX                                                  ~18
         14        SEND_VAL_EX                                                  <true>
         15        DO_FCALL                                          0          
    9    16        INIT_FCALL_BY_NAME                                           'curl_setopt'
         17        SEND_VAR_EX                                                  !1
         18        FETCH_CONSTANT                                       ~20     'CURLOPT_TIMEOUT'
         19        SEND_VAL_EX                                                  ~20
         20        SEND_VAL_EX                                                  5
         21        DO_FCALL                                          0          
   11    22        INIT_FCALL_BY_NAME                                           'curl_exec'
         23        SEND_VAR_EX                                                  !1
         24        DO_FCALL                                          0  $22     
         25        ASSIGN                                                       !2, $22
   12    26        INIT_FCALL_BY_NAME                                           'curl_getinfo'
         27        SEND_VAR_EX                                                  !1
         28        FETCH_CONSTANT                                       ~24     'CURLINFO_HTTP_CODE'
         29        SEND_VAL_EX                                                  ~24
         30        DO_FCALL                                          0  $25     
         31        ASSIGN                                                       !3, $25
   13    32        INIT_FCALL_BY_NAME                                           'curl_error'
         33        SEND_VAR_EX                                                  !1
         34        DO_FCALL                                          0  $27     
         35        ASSIGN                                                       !4, $27
   15    36        INIT_FCALL_BY_NAME                                           'curl_close'
         37        SEND_VAR_EX                                                  !1
         38        DO_FCALL                                          0          
   18    39        TYPE_CHECK                                        4          !2
         40      > JMPZ                                                         ~30, ->45
   19    41    > > INIT_FCALL                                                   'exit'
         42*       CONCAT                                               ~31     'Errore+nella+chiamata+cURL%3A+', !4
         43*       SEND_VAL                                                     ~31
         44*       DO_ICALL                                                     
   22    45    >   IS_NOT_IDENTICAL                                             !3, 200
         46      > JMPZ                                                         ~33, ->51
   23    47    > > INIT_FCALL                                                   'exit'
         48*       CONCAT                                               ~34     'L%27API+ha+risposto+con+codice+HTTP%3A+', !3
         49*       SEND_VAL                                                     ~34
         50*       DO_ICALL                                                     
   27    51    >   INIT_FCALL                                                   'json_decode'
         52        SEND_VAR                                                     !2
         53        SEND_VAL                                                     <true>
         54        DO_ICALL                                             $36     
         55        ASSIGN                                                       !5, $36
   29    56        TYPE_CHECK                                        2          !5
         57      > JMPZ                                                         ~38, ->61
   30    58    > > INIT_FCALL                                                   'exit'
         59*       SEND_VAL                                                     'Errore+nella+decodifica+del+JSON.'
         60*       DO_ICALL                                                     
   49    61    >   FETCH_DIM_R                                          ~40     !5, 'hourly'
         62        FETCH_DIM_R                                          ~41     ~40, 'time'
         63        ASSIGN                                                       !6, ~41
   50    64        FETCH_DIM_R                                          ~43     !5, 'hourly'
         65        FETCH_DIM_R                                          ~44     ~43, 'temperature_2m'
         66        ASSIGN                                                       !7, ~44
   51    67        FETCH_DIM_R                                          ~46     !5, 'hourly'
         68        FETCH_DIM_R                                          ~47     ~46, 'relative_humidity_2m'
         69        ASSIGN                                                       !8, ~47
   52    70        FETCH_DIM_R                                          ~49     !5, 'hourly'
         71        FETCH_DIM_R                                          ~50     ~49, 'weather_code'
         72        ASSIGN                                                       !9, ~50
   54    73        ECHO                                                         '%0A%3C%21DOCTYPE+html%3E%0A%3Chtml+lang%3D%22it%22%3E%0A%3Chead%3E%0A++++%3Cmeta+charset%3D%22UTF-8%22%3E%0A++++%3Ctitle%3ETest+API+Open-Meteo%3C%2Ftitle%3E%0A++++%3Cstyle%3E%0A++++++++body+%7B+font-family%3A+Arial%2C+sans-serif%3B+margin%3A+20px%3B+background-color%3A+%23f4f4f9%3B+%7D%0A++++++++table+%7B+border-collapse%3A+collapse%3B+width%3A+100%25%3B+max-width%3A+800px%3B+background%3A+%23fff%3B+%7D%0A++++++++th%2C+td+%7B+border%3A+1px+solid+%23ddd%3B+padding%3A+8px+12px%3B+text-align%3A+left%3B+%7D%0A++++++++th+%7B+background-color%3A+%23007bff%3B+color%3A+white%3B+%7D%0A++++++++tr%3Anth-child%28even%29+%7B+background-color%3A+%23f9f9f9%3B+%7D%0A++++%3C%2Fstyle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%0A++++%3Ch2%3EPrevisioni+Orarie+Grosseto+%2848+ore%29%3C%2Fh2%3E%0A++++%3Cp%3E%3Cstrong%3EUnit%C3%A0+di+misura%3A%3C%2Fstrong%3E+Temperatura+%28%C2%B0C%29%2C+Umidit%C3%A0+%28%25%29%3C%2Fp%3E%0A%0A++++%3Ctable%3E%0A++++++++%3Cthead%3E%0A++++++++++++%3Ctr%3E%0A++++++++++++++++%3Cth%3EData+e+Ora%3C%2Fth%3E%0A++++++++++++++++%3Cth%3EMeteo%3C%2Fth%3E%0A++++++++++++++++%3Cth%3ETemperatura+%28%C2%B0C%29%3C%2Fth%3E%0A++++++++++++++++%3Cth%3EUmidit%C3%A0+%28%25%29%3C%2Fth%3E%0A++++++++++++%3C%2Ftr%3E%0A++++++++%3C%2Fthead%3E%0A++++++++%3Ctbody%3E%0A++++++++++++'
   85    74        COUNT                                                ~52     !6
         75        ASSIGN                                                       !10, ~52
   86    76        ASSIGN                                                       !11, 0
         77      > JMP                                                          ->103
   88    78    >   INIT_FCALL                                                   'date'
         79        SEND_VAL                                                     'd%2Fm%2FY+H%3Ai'
         80        INIT_FCALL                                                   'strtotime'
         81        FETCH_DIM_R                                          ~55     !6, !11
         82        SEND_VAL                                                     ~55
         83        DO_ICALL                                             $56     
         84        SEND_VAR                                                     $56
         85        DO_ICALL                                             $57     
         86        ASSIGN                                                       !12, $57
   90    87        ECHO                                                         '++++++++++++++++%3Ctr%3E%0A++++++++++++++++++++%3Ctd%3E'
   91    88        ECHO                                                         !12
         89        ECHO                                                         '%3C%2Ftd%3E%0A++++++++++++++++++++%3Ctd%3E'
   92    90        INIT_FCALL                                                   'decodificameteocode'
         91        FETCH_DIM_R                                          ~59     !9, !11
         92        SEND_VAL                                                     ~59
         93        DO_FCALL                                          0  $60     
         94        ECHO                                                         $60
         95        ECHO                                                         '%3C%2Ftd%3E%0A++++++++++++++++++++%3Ctd%3E'
   93    96        FETCH_DIM_R                                          ~61     !7, !11
         97        ECHO                                                         ~61
         98        ECHO                                                         '+%C2%B0C%3C%2Ftd%3E%0A++++++++++++++++++++%3Ctd%3E'
   94    99        FETCH_DIM_R                                          ~62     !8, !11
        100        ECHO                                                         ~62
        101        ECHO                                                         '+%25%3C%2Ftd%3E%0A++++++++++++++++%3C%2Ftr%3E%0A++++++++++++'
   86   102        PRE_INC                                                      !11
        103    >   IS_SMALLER                                                   !11, !10
        104      > JMPNZ                                                        ~64, ->78
   97   105    >   ECHO                                                         '++++++++%3C%2Ftbody%3E%0A++++%3C%2Ftable%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
  101   106      > 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/QCcOM
function name:  decodificaMeteoCode
number of ops:  27
compiled vars:  !0 = $code
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E >   RECV                                                 !0      
   35     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
   36     2    >   QM_ASSIGN                                            ~2      'Cielo+sereno+%E2%98%80%EF%B8%8F'
          3      > JMP                                                          ->23
   37     4    >   QM_ASSIGN                                            ~2      'Prevalentemente+sereno+%2F+Nuvoloso+%E2%9B%85'
          5      > JMP                                                          ->23
   38     6    >   QM_ASSIGN                                            ~2      'Nebbia+%F0%9F%8C%AB%EF%B8%8F'
          7      > JMP                                                          ->23
   39     8    >   QM_ASSIGN                                            ~2      'Pioggerella+%F0%9F%8C%A7%EF%B8%8F'
          9      > JMP                                                          ->23
   40    10    >   QM_ASSIGN                                            ~2      'Pioggia+%F0%9F%8C%A7%EF%B8%8F'
         11      > JMP                                                          ->23
   41    12    >   QM_ASSIGN                                            ~2      'Neve+%E2%9D%84%EF%B8%8F'
         13      > JMP                                                          ->23
   42    14    >   QM_ASSIGN                                            ~2      'Rovesci+di+pioggia+%F0%9F%8C%A6%EF%B8%8F'
         15      > JMP                                                          ->23
   43    16    >   QM_ASSIGN                                            ~2      'Temporale+%F0%9F%8C%A9%EF%B8%8F'
         17      > JMP                                                          ->23
   44    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
   46    25*       VERIFY_RETURN_TYPE                                           
         26*     > RETURN                                                       null

End of function decodificameteocode

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
131.87 ms | 501 KiB | 12 Q