3v4l.org

run code in 300+ PHP versions simultaneously
<?php function validateTwoDecimalOrNull($number) { if($number == null || preg_match('/^[0-9]+\.[0-9]{2}$/', $number)) return true; else return false; } echo "Greater than 2 decimal places=".validateTwoDecimalOrNull(12.22444); echo PHP_EOL; echo "Null value=".validateTwoDecimalOrNull(null); echo PHP_EOL; echo "2 decimal places=".validateTwoDecimalOrNull(12.22); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLZs4
function name:  (null)
number of ops:  18
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'validatetwodecimalornull'
          1        SEND_VAL                                                 12.2244
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      'Greater+than+2+decimal+places%3D', $0
          4        ECHO                                                     ~1
   11     5        ECHO                                                     '%0A'
   12     6        INIT_FCALL                                               'validatetwodecimalornull'
          7        SEND_VAL                                                 null
          8        DO_FCALL                                      0  $2      
          9        CONCAT                                           ~3      'Null+value%3D', $2
         10        ECHO                                                     ~3
   13    11        ECHO                                                     '%0A'
   14    12        INIT_FCALL                                               'validatetwodecimalornull'
         13        SEND_VAL                                                 12.22
         14        DO_FCALL                                      0  $4      
         15        CONCAT                                           ~5      '2+decimal+places%3D', $4
         16        ECHO                                                     ~5
   15    17      > RETURN                                                   1

Function validatetwodecimalornull:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/vLZs4
function name:  validateTwoDecimalOrNull
number of ops:  13
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        IS_EQUAL                                         ~1      !0, null
          2      > JMPNZ_EX                                         ~1      ~1, ->8
          3    >   INIT_FCALL                                               'preg_match'
          4        SEND_VAL                                                 '%2F%5E%5B0-9%5D%2B%5C.%5B0-9%5D%7B2%7D%24%2F'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        BOOL                                             ~1      $2
          8    > > JMPZ                                                     ~1, ->11
    5     9    > > RETURN                                                   <true>
         10*       JMP                                                      ->12
    7    11    > > RETURN                                                   <false>
    8    12*     > RETURN                                                   null

End of function validatetwodecimalornull

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.19 ms | 1403 KiB | 18 Q