3v4l.org

run code in 500+ PHP versions simultaneously
<?php function absint( $maybeint ) { return abs( (int) $maybeint ); } function new_absint( $maybeint ): int { $maybeint = (int) $maybeint; if ( PHP_INT_MIN === $maybeint ) { // `abs( PHP_INT_MIN )` overflows to a float, as `PHP_INT_MAX` is `-PHP_INT_MIN`. return PHP_INT_MAX; } return abs( $maybeint ); } #$data = '999 stuff'; // same #$data = '999999999999999999222222222288888888888888222222222227777777774444'; // same, warning is gone in newer version of PHP 8.5 ( 8.5.2+ ) #$data = -PHP_INT_MIN; // original: float, new: int -- and the numbers differ by 1 #$data = 'now is the time'; // same ( zero ) #$data = -PHP_INT_MAX; // same #$data = PHP_INT_MAX + 1; // original: float ( 9.223372036854776E+18 ), new: int ( 9223372036854775807 ) -- very different numbers $data = PHP_INT_MIN - 1; // original: float( 9.223372036854776E+18 ), new: int( 9223372036854775807 ) -- very different numbers var_dump( $data ); var_dump( absint( $data ) ); var_dump( new_absint( $data ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MssWC
function name:  (null)
number of ops:  17
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                       !0, -9.22337e+18
   27     1        INIT_FCALL                                                   'var_dump'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                                     
   28     4        INIT_FCALL                                                   'var_dump'
          5        INIT_FCALL                                                   'absint'
          6        SEND_VAR                                                     !0
          7        DO_FCALL                                          0  $3      
          8        SEND_VAR                                                     $3
          9        DO_ICALL                                                     
   29    10        INIT_FCALL                                                   'var_dump'
         11        INIT_FCALL                                                   'new_absint'
         12        SEND_VAR                                                     !0
         13        DO_FCALL                                          0  $5      
         14        SEND_VAR                                                     $5
         15        DO_ICALL                                                     
         16      > RETURN                                                       1

Function absint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MssWC
function name:  absint
number of ops:  7
compiled vars:  !0 = $maybeint
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'abs'
          2        CAST                                              4  ~1      !0
          3        SEND_VAL                                                     ~1
          4        DO_ICALL                                             $2      
          5      > RETURN                                                       $2
    5     6*     > RETURN                                                       null

End of function absint

Function new_absint:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MssWC
function name:  new_absint
number of ops:  13
compiled vars:  !0 = $maybeint
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        CAST                                              4  ~1      !0
          2        ASSIGN                                                       !0, ~1
   10     3        IS_IDENTICAL                                                 !0, -9223372036854775808
          4      > JMPZ                                                         ~3, ->6
   12     5    > > RETURN                                                       9223372036854775807
   15     6    >   INIT_FCALL                                                   'abs'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                             $4      
          9        VERIFY_RETURN_TYPE                                           $4
         10      > RETURN                                                       $4
   16    11*       VERIFY_RETURN_TYPE                                           
         12*     > RETURN                                                       null

End of function new_absint

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.97 ms | 1422 KiB | 17 Q