3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decimal($check, $args) { $maxFractionalPlaces = isset($args[0]) ? $args[0] : 2; $maxIntegralPlaces = isset($args[1]) ? $args[1] : null; $allFractionalPlacesRequired = isset($args[2]) ? $args[2] : false; $seperator = t('common.decimalSeperator'); if ($seperator == 'common.decimalSeperator') { $seperator = '.'; } if ($seperator != '.') { $check = str_replace($seperator, '.', $check); } if (!is_numeric($check)) { return false; } if (!$allFractionalPlacesRequired) { $fractionalRegex = '\\.[0-9]{0,' . $maxFractionalPlaces . '}'; } else { $fractionalRegex = '\\.[0-9]{' . $maxFractionalPlaces . '}'; } if ($maxIntegralPlaces > 0) { $integralRegex = '[-+]?[0-9]{0,' . $maxIntegralPlaces . '}'; } else { $integralRegex = '[-+]?[0-9]*'; } $regex = '/^' . $integralRegex . $fractionalRegex . '$/'; if (!$allFractionalPlacesRequired) { if (preg_match('/^' . $integralRegex . '$/', $check) || preg_match($regex, $check)) { return true; } } else { if (preg_match($regex, $check)) { return true; } } return false; } var_dump(decimal(1.8867 ,array(4, 10)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FPBUG
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'decimal'
          2        SEND_VAL                                                 1.8867
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function decimal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 44
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 50
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 81
Branch analysis from position: 66
2 jumps found. (Code = 47) Position 1 = 73, Position 2 = 78
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 80
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 87
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 87
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 81
Branch analysis from position: 66
Branch analysis from position: 81
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
Branch analysis from position: 59
Branch analysis from position: 38
Branch analysis from position: 30
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
Branch analysis from position: 30
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
Branch analysis from position: 21
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
Branch analysis from position: 14
filename:       /in/FPBUG
function name:  decimal
number of ops:  89
compiled vars:  !0 = $check, !1 = $args, !2 = $maxFractionalPlaces, !3 = $maxIntegralPlaces, !4 = $allFractionalPlacesRequired, !5 = $seperator, !6 = $fractionalRegex, !7 = $integralRegex, !8 = $regex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 0
          3      > JMPZ                                                     ~9, ->7
          4    >   FETCH_DIM_R                                      ~10     !1, 0
          5        QM_ASSIGN                                        ~11     ~10
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~11     2
          8    >   ASSIGN                                                   !2, ~11
    5     9        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 1
         10      > JMPZ                                                     ~13, ->14
         11    >   FETCH_DIM_R                                      ~14     !1, 1
         12        QM_ASSIGN                                        ~15     ~14
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~15     null
         15    >   ASSIGN                                                   !3, ~15
    6    16        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 2
         17      > JMPZ                                                     ~17, ->21
         18    >   FETCH_DIM_R                                      ~18     !1, 2
         19        QM_ASSIGN                                        ~19     ~18
         20      > JMP                                                      ->22
         21    >   QM_ASSIGN                                        ~19     <false>
         22    >   ASSIGN                                                   !4, ~19
    7    23        INIT_FCALL_BY_NAME                                       't'
         24        SEND_VAL_EX                                              'common.decimalSeperator'
         25        DO_FCALL                                      0  $21     
         26        ASSIGN                                                   !5, $21
    8    27        IS_EQUAL                                                 !5, 'common.decimalSeperator'
         28      > JMPZ                                                     ~23, ->30
    9    29    >   ASSIGN                                                   !5, '.'
   12    30    >   IS_NOT_EQUAL                                             !5, '.'
         31      > JMPZ                                                     ~25, ->38
   13    32    >   INIT_FCALL                                               'str_replace'
         33        SEND_VAR                                                 !5
         34        SEND_VAL                                                 '.'
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $26     
         37        ASSIGN                                                   !0, $26
   16    38    >   INIT_FCALL                                               'is_numeric'
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $28     
         41        BOOL_NOT                                         ~29     $28
         42      > JMPZ                                                     ~29, ->44
   17    43    > > RETURN                                                   <false>
   20    44    >   BOOL_NOT                                         ~30     !4
         45      > JMPZ                                                     ~30, ->50
   21    46    >   CONCAT                                           ~31     '%5C.%5B0-9%5D%7B0%2C', !2
         47        CONCAT                                           ~32     ~31, '%7D'
         48        ASSIGN                                                   !6, ~32
         49      > JMP                                                      ->53
   23    50    >   CONCAT                                           ~34     '%5C.%5B0-9%5D%7B', !2
         51        CONCAT                                           ~35     ~34, '%7D'
         52        ASSIGN                                                   !6, ~35
   26    53    >   IS_SMALLER                                               0, !3
         54      > JMPZ                                                     ~37, ->59
   27    55    >   CONCAT                                           ~38     '%5B-%2B%5D%3F%5B0-9%5D%7B0%2C', !3
         56        CONCAT                                           ~39     ~38, '%7D'
         57        ASSIGN                                                   !7, ~39
         58      > JMP                                                      ->60
   29    59    >   ASSIGN                                                   !7, '%5B-%2B%5D%3F%5B0-9%5D%2A'
   32    60    >   CONCAT                                           ~42     '%2F%5E', !7
         61        CONCAT                                           ~43     ~42, !6
         62        CONCAT                                           ~44     ~43, '%24%2F'
         63        ASSIGN                                                   !8, ~44
   33    64        BOOL_NOT                                         ~46     !4
         65      > JMPZ                                                     ~46, ->81
   34    66    >   INIT_FCALL                                               'preg_match'
         67        CONCAT                                           ~47     '%2F%5E', !7
         68        CONCAT                                           ~48     ~47, '%24%2F'
         69        SEND_VAL                                                 ~48
         70        SEND_VAR                                                 !0
         71        DO_ICALL                                         $49     
         72      > JMPNZ_EX                                         ~50     $49, ->78
         73    >   INIT_FCALL                                               'preg_match'
         74        SEND_VAR                                                 !8
         75        SEND_VAR                                                 !0
         76        DO_ICALL                                         $51     
         77        BOOL                                             ~50     $51
         78    > > JMPZ                                                     ~50, ->80
   35    79    > > RETURN                                                   <true>
         80    > > JMP                                                      ->87
   38    81    >   INIT_FCALL                                               'preg_match'
         82        SEND_VAR                                                 !8
         83        SEND_VAR                                                 !0
         84        DO_ICALL                                         $52     
         85      > JMPZ                                                     $52, ->87
   39    86    > > RETURN                                                   <true>
   42    87    > > RETURN                                                   <false>
   43    88*     > RETURN                                                   null

End of function decimal

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.8 ms | 1407 KiB | 22 Q