3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tsId = 'XACCB84E44344C2EEB8714B3210DE2907'; $cacheFileName = $tsId.'.xml'; $cacheTimeOut = 43200; // half a day $apiUrl = 'http://www.trustedshops.com/api/ratings/v1/'.$tsId.'.xml'; $xmlFound = false;// check if cached version exists if (!cachecheck($cacheFileName, $cacheTimeOut)) { // load fresh from API $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_URL, $apiUrl); $output = curl_exec($ch); curl_close($ch); // Write the contents back to the file // Make sure you can write to file's destination file_put_contents($cacheFileName, $output);} if ($xml = simplexml_load_file($cacheFileName)) { $xPath = "/shop/ratings/result[@name='average']"; $result = (float) $xml -> xpath($xPath)[0]; $max = "5.00"; $count = $xml->ratings["amount"]; $shopName = $xml->name; $xmlFound = true;}if ($xmlFound) { ?> <a href="http://www.trustedshops.eu/seller-rating/">Trusted Shops seller rating</a>:<span xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review-aggregate"> <span rel="v:rating"><span property="v:value"><?php echo $result;?> </span> </span> / <span property="v:best"><?php echo $max;?> </span> of <span property="v:count"><?php echo $count;?> </span> <a href="https://www.trustedshops.de/bewertung/info_<?php echo $tsId?>.html" title="<?php echo $shopName;?> bewertungen"> <?php echo $shopName;?> ratings</a> </span> <?php } function cachecheck($filename_cache, $timeout = 10800) { if (file_exists($filename_cache) && time() - filemtime($filename_cache) < $timeout) { return true; } return false; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 52
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 71
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 85
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
Branch analysis from position: 71
Branch analysis from position: 52
filename:       /in/aCUZc
function name:  (null)
number of ops:  86
compiled vars:  !0 = $tsId, !1 = $cacheFileName, !2 = $cacheTimeOut, !3 = $apiUrl, !4 = $xmlFound, !5 = $ch, !6 = $output, !7 = $xml, !8 = $xPath, !9 = $result, !10 = $max, !11 = $count, !12 = $shopName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'XACCB84E44344C2EEB8714B3210DE2907'
    3     1        CONCAT                                           ~14     !0, '.xml'
          2        ASSIGN                                                   !1, ~14
    4     3        ASSIGN                                                   !2, 43200
    5     4        CONCAT                                           ~17     'http%3A%2F%2Fwww.trustedshops.com%2Fapi%2Fratings%2Fv1%2F', !0
          5        CONCAT                                           ~18     ~17, '.xml'
          6        ASSIGN                                                   !3, ~18
    6     7        ASSIGN                                                   !4, <false>
    7     8        INIT_FCALL_BY_NAME                                       'cachecheck'
          9        SEND_VAR_EX                                              !1
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0  $21     
         12        BOOL_NOT                                         ~22     $21
         13      > JMPZ                                                     ~22, ->52
    9    14    >   INIT_FCALL_BY_NAME                                       'curl_init'
         15        DO_FCALL                                      0  $23     
         16        ASSIGN                                                   !5, $23
   10    17        INIT_FCALL_BY_NAME                                       'curl_setopt'
         18        SEND_VAR_EX                                              !5
         19        FETCH_CONSTANT                                   ~25     'CURLOPT_HEADER'
         20        SEND_VAL_EX                                              ~25
         21        SEND_VAL_EX                                              <false>
         22        DO_FCALL                                      0          
   11    23        INIT_FCALL_BY_NAME                                       'curl_setopt'
         24        SEND_VAR_EX                                              !5
         25        FETCH_CONSTANT                                   ~27     'CURLOPT_RETURNTRANSFER'
         26        SEND_VAL_EX                                              ~27
         27        SEND_VAL_EX                                              1
         28        DO_FCALL                                      0          
   12    29        INIT_FCALL_BY_NAME                                       'curl_setopt'
         30        SEND_VAR_EX                                              !5
         31        FETCH_CONSTANT                                   ~29     'CURLOPT_POST'
         32        SEND_VAL_EX                                              ~29
         33        SEND_VAL_EX                                              <false>
         34        DO_FCALL                                      0          
   13    35        INIT_FCALL_BY_NAME                                       'curl_setopt'
         36        SEND_VAR_EX                                              !5
         37        FETCH_CONSTANT                                   ~31     'CURLOPT_URL'
         38        SEND_VAL_EX                                              ~31
         39        SEND_VAR_EX                                              !3
         40        DO_FCALL                                      0          
   14    41        INIT_FCALL_BY_NAME                                       'curl_exec'
         42        SEND_VAR_EX                                              !5
         43        DO_FCALL                                      0  $33     
         44        ASSIGN                                                   !6, $33
   15    45        INIT_FCALL_BY_NAME                                       'curl_close'
         46        SEND_VAR_EX                                              !5
         47        DO_FCALL                                      0          
   18    48        INIT_FCALL                                               'file_put_contents'
         49        SEND_VAR                                                 !1
         50        SEND_VAR                                                 !6
         51        DO_ICALL                                                 
   19    52    >   INIT_FCALL                                               'simplexml_load_file'
         53        SEND_VAR                                                 !1
         54        DO_ICALL                                         $37     
         55        ASSIGN                                           ~38     !7, $37
         56      > JMPZ                                                     ~38, ->71
   20    57    >   ASSIGN                                                   !8, '%2Fshop%2Fratings%2Fresult%5B%40name%3D%27average%27%5D'
   21    58        INIT_METHOD_CALL                                         !7, 'xpath'
         59        SEND_VAR_EX                                              !8
         60        DO_FCALL                                      0  $40     
         61        FETCH_DIM_R                                      ~41     $40, 0
         62        CAST                                          5  ~42     ~41
         63        ASSIGN                                                   !9, ~42
   22    64        ASSIGN                                                   !10, '5.00'
   23    65        FETCH_OBJ_R                                      ~45     !7, 'ratings'
         66        FETCH_DIM_R                                      ~46     ~45, 'amount'
         67        ASSIGN                                                   !11, ~46
   24    68        FETCH_OBJ_R                                      ~48     !7, 'name'
         69        ASSIGN                                                   !12, ~48
   25    70        ASSIGN                                                   !4, <true>
         71    > > JMPZ                                                     !4, ->85
   27    72    >   ECHO                                                     '%3Ca+href%3D%22http%3A%2F%2Fwww.trustedshops.eu%2Fseller-rating%2F%22%3ETrusted+Shops+seller+rating%3C%2Fa%3E%3A%3Cspan+xmlns%3Av%3D%22http%3A%2F%2Frdf.data-vocabulary.org%2F%23%22+typeof%3D%22v%3AReview-aggregate%22%3E+%3Cspan+rel%3D%22v%3Arating%22%3E%3Cspan+property%3D%22v%3Avalue%22%3E'
         73        ECHO                                                     !9
         74        ECHO                                                     '+%3C%2Fspan%3E+%3C%2Fspan%3E+%2F+%3Cspan+property%3D%22v%3Abest%22%3E'
         75        ECHO                                                     !10
         76        ECHO                                                     '+%3C%2Fspan%3E+of+%3Cspan+property%3D%22v%3Acount%22%3E'
   28    77        ECHO                                                     !11
         78        ECHO                                                     '+%3C%2Fspan%3E+%3Ca+href%3D%22https%3A%2F%2Fwww.trustedshops.de%2Fbewertung%2Finfo_'
         79        ECHO                                                     !0
         80        ECHO                                                     '.html%22+title%3D%22'
         81        ECHO                                                     !12
         82        ECHO                                                     '+bewertungen%22%3E%0A'
   29    83        ECHO                                                     !12
         84        ECHO                                                     '+ratings%3C%2Fa%3E+%3C%2Fspan%3E%0A'
   35    85    > > RETURN                                                   1

Function cachecheck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/aCUZc
function name:  cachecheck
number of ops:  18
compiled vars:  !0 = $filename_cache, !1 = $timeout
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      10800
   33     2        INIT_FCALL                                               'file_exists'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5      > JMPZ_EX                                          ~3      $2, ->14
          6    >   INIT_FCALL                                               'time'
          7        DO_ICALL                                         $4      
          8        INIT_FCALL                                               'filemtime'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        SUB                                              ~6      $4, $5
         12        IS_SMALLER                                       ~7      ~6, !1
         13        BOOL                                             ~3      ~7
         14    > > JMPZ                                                     ~3, ->16
   34    15    > > RETURN                                                   <true>
   35    16    > > RETURN                                                   <false>
         17*     > RETURN                                                   null

End of function cachecheck

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.09 ms | 1404 KiB | 23 Q