3v4l.org

run code in 300+ PHP versions simultaneously
<?php # how i can round 4.3 to 4.5, 4.2 to 4.0, 4.7 to 4.5 and 4.8 to 5.0 ? function bogoround($x) { static $calls = 0; $results = [4.5,4.0,4.5,5.0]; return $results[$calls++]; } var_dump(bogoround(4.3)); var_dump(bogoround(4.2)); var_dump(bogoround(4.7)); var_dump(bogoround(4.8));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4o0oh
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'bogoround'
          2        SEND_VAL                                                 4.3
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   15     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'bogoround'
          8        SEND_VAL                                                 4.2
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   16    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'bogoround'
         14        SEND_VAL                                                 4.7
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   17    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'bogoround'
         20        SEND_VAL                                                 4.8
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function bogoround:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4o0oh
function name:  bogoround
number of ops:  7
compiled vars:  !0 = $x, !1 = $calls, !2 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        BIND_STATIC                                              !1
   10     2        ASSIGN                                                   !2, <array>
   11     3        POST_INC                                         ~4      !1
          4        FETCH_DIM_R                                      ~5      !2, ~4
          5      > RETURN                                                   ~5
   12     6*     > RETURN                                                   null

End of function bogoround

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.95 ms | 1390 KiB | 19 Q