3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_natural($val) { $val = (string)$val; return (bool)ctype_digit($val) && $val === (string)(int)$val && $val > 0; } var_dump(is_natural(15)); // true var_dump(is_natural(0)); // false var_dump(is_natural(-1)); // false var_dump(is_natural('5')); // true var_dump(is_natural('01')); // false var_dump(is_natural('1.5')); // false var_dump(is_natural('0x18')); // false
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DHWR9
function name:  (null)
number of ops:  43
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'is_natural'
          2        SEND_VAL                                                 15
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
    7     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'is_natural'
          8        SEND_VAL                                                 0
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
    8    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'is_natural'
         14        SEND_VAL                                                 -1
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
    9    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'is_natural'
         20        SEND_VAL                                                 '5'
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
   10    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'is_natural'
         26        SEND_VAL                                                 '01'
         27        DO_FCALL                                      0  $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                                 
   11    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'is_natural'
         32        SEND_VAL                                                 '1.5'
         33        DO_FCALL                                      0  $10     
         34        SEND_VAR                                                 $10
         35        DO_ICALL                                                 
   12    36        INIT_FCALL                                               'var_dump'
         37        INIT_FCALL                                               'is_natural'
         38        SEND_VAL                                                 '0x18'
         39        DO_FCALL                                      0  $12     
         40        SEND_VAR                                                 $12
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Function is_natural:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 12
filename:       /in/DHWR9
function name:  is_natural
number of ops:  17
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        CAST                                          6  ~1      !0
          2        ASSIGN                                                   !0, ~1
    4     3        INIT_FCALL                                               'ctype_digit'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        BOOL                                             ~4      $3
          7      > JMPZ_EX                                          ~4      ~4, ->12
          8    >   CAST                                          4  ~5      !0
          9        CAST                                          6  ~6      ~5
         10        IS_IDENTICAL                                     ~7      !0, ~6
         11        BOOL                                             ~4      ~7
         12    > > JMPZ_EX                                          ~4      ~4, ->15
         13    >   IS_SMALLER                                       ~8      0, !0
         14        BOOL                                             ~4      ~8
         15    > > RETURN                                                   ~4
    5    16*     > RETURN                                                   null

End of function is_natural

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.35 ms | 1403 KiB | 24 Q