3v4l.org

run code in 300+ PHP versions simultaneously
<?php function checkFloat(&$var) { if (is_float($var) || is_numeric($var)) { $var = unpack("f", pack("f", $var))[1]; } else { throw new \Exception("Expect float."); } } $var = 0.9; checkFloat($var); var_dump($var); $var = 0.7; checkFloat($var); var_dump($var); $var = 0.3; checkFloat($var); var_dump($var); $var = 0.1; checkFloat($var); var_dump($var);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CgGYZ
function name:  (null)
number of ops:  29
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, 0.9
   13     1        INIT_FCALL                                               'checkfloat'
          2        SEND_REF                                                 !0
          3        DO_FCALL                                      0          
   14     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   16     7        ASSIGN                                                   !0, 0.7
   17     8        INIT_FCALL                                               'checkfloat'
          9        SEND_REF                                                 !0
         10        DO_FCALL                                      0          
   18    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   20    14        ASSIGN                                                   !0, 0.3
   21    15        INIT_FCALL                                               'checkfloat'
         16        SEND_REF                                                 !0
         17        DO_FCALL                                      0          
   22    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   24    21        ASSIGN                                                   !0, 0.1
   25    22        INIT_FCALL                                               'checkfloat'
         23        SEND_REF                                                 !0
         24        DO_FCALL                                      0          
   26    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function checkfloat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
filename:       /in/CgGYZ
function name:  checkFloat
number of ops:  24
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        TYPE_CHECK                                   32  ~1      !0
          2      > JMPNZ_EX                                         ~1      ~1, ->7
          3    >   INIT_FCALL                                               'is_numeric'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        BOOL                                             ~1      $2
          7    > > JMPZ                                                     ~1, ->19
    6     8    >   INIT_FCALL                                               'unpack'
          9        SEND_VAL                                                 'f'
         10        INIT_FCALL                                               'pack'
         11        SEND_VAL                                                 'f'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $3      
         14        SEND_VAR                                                 $3
         15        DO_ICALL                                         $4      
         16        FETCH_DIM_R                                      ~5      $4, 1
         17        ASSIGN                                                   !0, ~5
    5    18      > JMP                                                      ->23
    8    19    >   NEW                                              $7      'Exception'
         20        SEND_VAL_EX                                              'Expect+float.'
         21        DO_FCALL                                      0          
         22      > THROW                                         0          $7
   10    23    > > RETURN                                                   null

End of function checkfloat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.78 ms | 1012 KiB | 21 Q