3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = array( 20/3, 20/3 * 1e6, 6.66, 6.0, 60.0, 60.06 ); $p = (int) ini_get('precision'); foreach ($numbers as $n) { echo 'RAW: ' . $n . "\n"; echo 'EXP: ' . var_export($n, TRUE) . "\n"; echo 'FIX: ' . rtrim(rtrim(sprintf('%.' . ($p - ceil(log10($n))) . 'F', $n), '0'), '.') . "\n"; echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 44
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 44
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/F88Nh
function name:  (null)
number of ops:  46
compiled vars:  !0 = $numbers, !1 = $p, !2 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'ini_get'
          2        SEND_VAL                                                 'precision'
          3        DO_ICALL                                         $4      
          4        CAST                                          4  ~5      $4
          5        ASSIGN                                                   !1, ~5
   14     6      > FE_RESET_R                                       $7      !0, ->44
          7    > > FE_FETCH_R                                               $7, !2, ->44
   15     8    >   CONCAT                                           ~8      'RAW%3A+', !2
          9        CONCAT                                           ~9      ~8, '%0A'
         10        ECHO                                                     ~9
   16    11        INIT_FCALL                                               'var_export'
         12        SEND_VAR                                                 !2
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $10     
         15        CONCAT                                           ~11     'EXP%3A+', $10
         16        CONCAT                                           ~12     ~11, '%0A'
         17        ECHO                                                     ~12
   17    18        INIT_FCALL                                               'rtrim'
         19        INIT_FCALL                                               'rtrim'
         20        INIT_FCALL                                               'sprintf'
         21        INIT_FCALL                                               'ceil'
         22        INIT_FCALL                                               'log10'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $13     
         25        SEND_VAR                                                 $13
         26        DO_ICALL                                         $14     
         27        SUB                                              ~15     !1, $14
         28        CONCAT                                           ~16     '%25.', ~15
         29        CONCAT                                           ~17     ~16, 'F'
         30        SEND_VAL                                                 ~17
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                         $18     
         33        SEND_VAR                                                 $18
         34        SEND_VAL                                                 '0'
         35        DO_ICALL                                         $19     
         36        SEND_VAR                                                 $19
         37        SEND_VAL                                                 '.'
         38        DO_ICALL                                         $20     
         39        CONCAT                                           ~21     'FIX%3A+', $20
         40        CONCAT                                           ~22     ~21, '%0A'
         41        ECHO                                                     ~22
   18    42        ECHO                                                     '%0A'
   14    43      > JMP                                                      ->7
         44    >   FE_FREE                                                  $7
   19    45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.35 ms | 1400 KiB | 25 Q