3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_position($input) { $_POST['position'] = $input; // Original code $original = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; // Alternative 1: !empty() $empty_check = ! empty( $_POST['position'] ) ? (int) $_POST['position'] : -1; // Alternative 3: null coalescing operator $null_coalesce = (int) ($_POST['position'] ?? '-1'); echo "Input: $input\n"; echo "Original: $original\n"; echo "!empty() check: $empty_check\n"; echo "Null coalescing: $null_coalesce\n"; echo "-------------------------\n"; } // Test cases $test_inputs = ['5', '0', 'xyz', '', null]; foreach ($test_inputs as $input) { test_position($input); } ?>

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.4.120.0090.01020.43
8.4.110.0120.00418.82
8.4.100.0140.00717.77
8.4.90.0120.00817.68
8.4.80.0100.00919.68
8.4.70.0410.01217.55
8.4.60.0320.00917.63
8.4.50.0330.01317.53
8.4.40.0470.00717.54
8.4.30.0390.01017.42
8.4.20.0390.00817.58
8.4.10.0390.01017.35
8.3.250.0050.00318.95
8.3.240.0090.00916.61
8.3.230.0050.00916.75
8.3.220.0120.00716.96
8.3.210.0420.00716.53
8.3.200.0330.01016.56
8.3.190.0370.00616.54
8.3.180.0330.00616.59
8.3.170.0360.01116.65
8.3.160.0370.01016.49
8.3.150.0390.00916.29
8.3.140.0380.00716.45
8.3.130.0330.00716.54
8.3.120.0350.00716.46
8.3.110.0330.00916.49
8.3.100.0400.01116.45
8.3.90.0380.00916.54
8.3.80.0340.01116.41
8.3.70.0380.00916.43
8.3.60.0410.00916.32
8.3.50.0370.01116.32
8.3.40.0360.00717.38
8.3.30.0320.00717.49
8.3.20.0240.01117.65
8.3.10.0280.00817.41
8.3.00.0210.01018.37
8.2.290.0100.00818.75
8.2.280.0350.01016.49
8.2.270.0300.00716.41
8.2.260.0310.01216.34
8.2.250.0280.00616.69
8.2.240.0220.00616.60
8.2.230.0310.00916.30
8.2.220.0310.00916.44
8.2.210.0300.01016.26
8.2.200.0330.00916.31
8.2.190.0310.01016.25
8.2.180.0310.00916.35
8.2.170.0340.00917.69
8.2.160.0340.00817.68
8.2.150.0350.00717.76
8.2.140.0360.00717.40
8.2.130.0370.00917.58
8.2.120.0310.00617.60
8.2.110.0280.00717.53
8.2.100.0350.00717.63
8.2.90.0360.00617.72
8.2.80.0340.00717.51
8.2.70.0310.01017.52
8.2.60.0300.00917.55
8.2.50.0370.00717.40
8.2.40.0290.00717.55
8.2.30.0370.00717.66
8.2.20.0320.00917.46
8.2.10.0270.00817.55
8.2.00.0310.00917.49

preferences:
27.12 ms | 403 KiB | 5 Q