3v4l.org

run code in 300+ PHP versions simultaneously
<?php $number = 1234.56; // let's print the international format for the en_US locale setlocale(LC_MONETARY, 'en_US'); echo money_format('%i', $number) . "\n"; // USD 1,234.56 // Italian national format with 2 decimals` setlocale(LC_MONETARY, 'it_IT'); echo money_format('%.2n', $number) . "\n"; // Eu 1.234,56 // Using a negative number $number = -1234.5672; // US national format, using () for negative numbers // and 10 digits for left precision setlocale(LC_MONETARY, 'en_US'); echo money_format('%(#10n', $number) . "\n"; // ($ 1,234.57) // Similar format as above, adding the use of 2 digits of right // precision and '*' as a fill character echo money_format('%=*(#10.2n', $number) . "\n"; // ($********1,234.57) // Let's justify to the left, with 14 positions of width, 8 digits of // left precision, 2 of right precision, withouth grouping character // and using the international format for the de_DE locale. setlocale(LC_MONETARY, 'de_DE'); echo money_format('%=*^-14#8.2i', 1234.56) . "\n"; // Eu 1234,56**** // Let's add some blurb before and after the conversion specification setlocale(LC_MONETARY, 'en_GB'); $fmt = 'The final value is %i (after a 10%% discount)'; echo money_format($fmt, 1234.56) . "\n"; // The final value is GBP 1,234.56 (after a 10% discount)
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J3EDT
function name:  (null)
number of ops:  60
compiled vars:  !0 = $number, !1 = $fmt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 1234.56
    5     1        INIT_FCALL                                               'setlocale'
          2        SEND_VAL                                                 4
          3        SEND_VAL                                                 'en_US'
          4        DO_ICALL                                                 
    6     5        INIT_FCALL_BY_NAME                                       'money_format'
          6        SEND_VAL_EX                                              '%25i'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $4      
          9        CONCAT                                           ~5      $4, '%0A'
         10        ECHO                                                     ~5
   10    11        INIT_FCALL                                               'setlocale'
         12        SEND_VAL                                                 4
         13        SEND_VAL                                                 'it_IT'
         14        DO_ICALL                                                 
   11    15        INIT_FCALL_BY_NAME                                       'money_format'
         16        SEND_VAL_EX                                              '%25.2n'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $7      
         19        CONCAT                                           ~8      $7, '%0A'
         20        ECHO                                                     ~8
   15    21        ASSIGN                                                   !0, -1234.57
   19    22        INIT_FCALL                                               'setlocale'
         23        SEND_VAL                                                 4
         24        SEND_VAL                                                 'en_US'
         25        DO_ICALL                                                 
   20    26        INIT_FCALL_BY_NAME                                       'money_format'
         27        SEND_VAL_EX                                              '%25%28%2310n'
         28        SEND_VAR_EX                                              !0
         29        DO_FCALL                                      0  $11     
         30        CONCAT                                           ~12     $11, '%0A'
         31        ECHO                                                     ~12
   25    32        INIT_FCALL_BY_NAME                                       'money_format'
         33        SEND_VAL_EX                                              '%25%3D%2A%28%2310.2n'
         34        SEND_VAR_EX                                              !0
         35        DO_FCALL                                      0  $13     
         36        CONCAT                                           ~14     $13, '%0A'
         37        ECHO                                                     ~14
   31    38        INIT_FCALL                                               'setlocale'
         39        SEND_VAL                                                 4
         40        SEND_VAL                                                 'de_DE'
         41        DO_ICALL                                                 
   32    42        INIT_FCALL_BY_NAME                                       'money_format'
         43        SEND_VAL_EX                                              '%25%3D%2A%5E-14%238.2i'
         44        SEND_VAL_EX                                              1234.56
         45        DO_FCALL                                      0  $16     
         46        CONCAT                                           ~17     $16, '%0A'
         47        ECHO                                                     ~17
   36    48        INIT_FCALL                                               'setlocale'
         49        SEND_VAL                                                 4
         50        SEND_VAL                                                 'en_GB'
         51        DO_ICALL                                                 
   37    52        ASSIGN                                                   !1, 'The+final+value+is+%25i+%28after+a+10%25%25+discount%29'
   38    53        INIT_FCALL_BY_NAME                                       'money_format'
         54        SEND_VAR_EX                                              !1
         55        SEND_VAL_EX                                              1234.56
         56        DO_FCALL                                      0  $20     
         57        CONCAT                                           ~21     $20, '%0A'
         58        ECHO                                                     ~21
   39    59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.48 ms | 1400 KiB | 15 Q