3v4l.org

run code in 500+ PHP versions simultaneously
<?php function absint( $maybeint ) { return abs( (int) $maybeint ); } function new_absint( $maybeint ): int { if ( is_object( $maybeint ) ) { return 1; } if ( is_float( $maybeint ) ) { if ( ! is_finite( $maybeint ) ) { // Casting `NAN` or `INF` to int has produced `0` since PHP 7.0. return 0; } if ( $maybeint <= (float) PHP_INT_MIN || $maybeint >= (float) PHP_INT_MAX ) { // Casting a float beyond the integer range is unreliable and warns as of PHP 8.5. return PHP_INT_MAX; } } $maybeint = (int) $maybeint; if ( PHP_INT_MIN === $maybeint ) { // `abs( PHP_INT_MIN )` overflows to a float, as `PHP_INT_MAX` is one less than `-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 $data = new StdClass(); $data->name = 'data'; $data->place = 'where'; $data->stuff = [ 'green', 'blue', 'red' ]; var_dump( $data ); var_dump( absint( $data ) ); var_dump( new_absint( $data ) );

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.90.0340.01016.77
8.5.80.0330.00916.69
8.5.70.0370.00616.80
8.5.60.0340.00716.55
8.5.50.0330.00916.87
8.5.40.0340.00916.53
8.5.30.0370.00816.47
8.5.20.0360.00816.61
8.5.10.0330.00816.23
8.5.00.0100.00416.71
8.4.240.0390.01019.50
8.4.230.0310.01219.61
8.4.220.0410.01019.16
8.4.210.0250.01119.32
8.4.200.0170.00619.63
8.4.190.0150.00419.66
8.4.180.0160.00319.83
8.4.170.0260.00619.79
8.4.160.0320.01119.84
8.4.150.0310.01019.65
8.4.140.0320.01317.63
8.4.130.0370.00417.64
8.4.120.0320.01017.81
8.4.110.0310.01117.84
8.4.100.0370.00717.68
8.4.90.0360.01017.95
8.4.80.0360.01117.77
8.4.70.0290.01017.71
8.4.60.0380.00717.74
8.4.50.0370.00817.72
8.4.40.0360.01017.66
8.4.30.0360.00917.57
8.4.20.0370.00817.47
8.4.10.0360.00817.69
8.3.330.0470.01218.16
8.3.320.0350.00818.40
8.3.310.0310.00918.30
8.3.300.0300.01018.29
8.3.290.0300.00818.16
8.3.280.0320.01018.29
8.3.270.0340.00716.72
8.3.260.0300.01116.77
8.3.250.0320.01016.77
8.3.240.0320.00916.70
8.3.230.0320.01116.73
8.3.220.0350.00916.67
8.3.210.0360.00716.62
8.3.200.0300.00416.85
8.3.190.0310.00916.82
8.3.180.0320.01016.72
8.3.170.0290.00916.84
8.3.160.0360.00916.93
8.3.150.0330.01216.88
8.3.140.0350.01016.70
8.3.130.0310.00916.79
8.3.120.0320.01016.54
8.3.110.0250.00916.91
8.3.100.0300.01116.73
8.3.90.0350.00416.73
8.3.80.0360.00717.02
8.3.70.0360.00916.82
8.3.60.0350.00916.79
8.3.50.0370.00616.82
8.3.40.0280.01017.84
8.3.30.0240.01118.04
8.3.20.0280.00717.83
8.3.10.0270.00917.99
8.3.00.0290.00717.97
8.2.330.0480.00517.93
8.2.320.0280.00718.11
8.2.310.0140.00418.16

preferences:
43.41 ms | 802 KiB | 5 Q