3v4l.org

run code in 300+ PHP versions simultaneously
<?php $secret = 'MySecretFromSiruMobile'; $fields = [ 'variant' => 'variant1', 'merchantId' => '123123', 'purchaseCountry' => 'FI', 'basePrice' => '12.34', 'taxClass' => 3, 'serviceGroup' => 3, 'customerFirstname' => '', 'customerLastname' => null, 'customerNumber' => '050 123 4567', ]; $fields = array_filter($fields); // Drop empty fields echo 'UNSORTED'; $signature = hash_hmac("sha512", implode(';', $fields), $secret); ksort($fields); // Sort by field name foreach ($fruits as $key => $val) { echo "$key = $val\n"; } echo 'SORTED'; $signature = hash_hmac("sha512", implode(';', $fields), $secret); echo $signature; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/j0hOL
function name:  (null)
number of ops:  43
compiled vars:  !0 = $secret, !1 = $fields, !2 = $signature, !3 = $fruits, !4 = $val, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'MySecretFromSiruMobile'
    3     1        ASSIGN                                                   !1, <array>
   15     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   17     6        ECHO                                                     'UNSORTED'
   18     7        INIT_FCALL                                               'hash_hmac'
          8        SEND_VAL                                                 'sha512'
          9        INIT_FCALL                                               'implode'
         10        SEND_VAL                                                 '%3B'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $10     
         13        SEND_VAR                                                 $10
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !2, $11
   20    17        INIT_FCALL                                               'ksort'
         18        SEND_REF                                                 !1
         19        DO_ICALL                                                 
   22    20      > FE_RESET_R                                       $14     !3, ->29
         21    > > FE_FETCH_R                                       ~15     $14, !4, ->29
         22    >   ASSIGN                                                   !5, ~15
   23    23        ROPE_INIT                                     4  ~18     !5
         24        ROPE_ADD                                      1  ~18     ~18, '+%3D+'
         25        ROPE_ADD                                      2  ~18     ~18, !4
         26        ROPE_END                                      3  ~17     ~18, '%0A'
         27        ECHO                                                     ~17
   22    28      > JMP                                                      ->21
         29    >   FE_FREE                                                  $14
   26    30        ECHO                                                     'SORTED'
   27    31        INIT_FCALL                                               'hash_hmac'
         32        SEND_VAL                                                 'sha512'
         33        INIT_FCALL                                               'implode'
         34        SEND_VAL                                                 '%3B'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $20     
         37        SEND_VAR                                                 $20
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                         $21     
         40        ASSIGN                                                   !2, $21
   29    41        ECHO                                                     !2
   30    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.39 ms | 1392 KiB | 21 Q