3v4l.org

run code in 300+ PHP versions simultaneously
<?php function restrict_posting_points( $user_id, $activity_value, $activity_id, $activity_type ) { $max_posts_per_day = 2; $user_id = $user_id; $key = 'daily_post_count'; $single = true; $daily_post_count = get_user_meta($user_id, $key, $single); // create the meta data for the user's first post // *TODO* should this be added to the user creation step? if ( $daily_post_count == '' ) { $values = [ 'post_count' => 0, 'expiry_date' => strtotime( 'tomorrow' ), ]; add_user_meta( $user_id, $key, $values ); $daily_post_count = get_user_meta($user_id, $key, $single); } $num_posts = $daily_post_count['post_count']; // a new day has passed, reset the daily post count if ( time() > $daily_post_count['expiry_date'] ) { $num_posts = 0; $daily_post_count['expiry_date'] = strtotime('tomorrow'); } // full points are awarded for the first two posts of the day if ( $num_posts < $max_posts_per_day ) { $num_posts ++; $values = [ 'post_count' => $num_posts, 'expiry_date' => strtotime( 'tomorrow' ), ]; update_user_meta($user_id, $key, $values); return $activity_value; } return 0; } ?>

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)
7.3.00.0030.00716.36
7.2.130.0040.01116.62
7.2.120.0070.00716.43
7.2.110.0000.01216.58
7.2.100.0040.00716.84
7.2.90.0060.00616.71
7.2.80.0060.00316.56
7.2.70.0060.00616.78
7.2.60.0030.01416.88
7.2.50.0090.00316.40
7.2.40.0080.00816.83
7.2.30.0040.00716.68
7.2.20.0030.00816.77
7.2.10.0000.00816.54
7.2.00.0020.01217.94
7.1.250.0030.00715.82
7.1.240.0040.00415.69
7.1.230.0030.01015.66
7.1.220.0000.00815.72
7.1.210.0090.00315.58
7.1.200.0070.00315.59
7.1.190.0030.00715.58
7.1.180.0000.00915.30
7.1.170.0000.00915.70
7.1.160.0060.00315.68
7.1.150.0000.00715.52
7.1.140.0030.00915.73
7.1.130.0000.00815.38
7.1.120.0070.00715.61
7.1.110.0040.00415.56
7.1.100.0010.00916.91
7.1.90.0070.00015.33
7.1.80.0060.00615.79
7.1.70.0030.01216.25
7.1.60.0030.00816.38
7.1.50.0080.01015.88
7.1.40.0030.00715.35
7.1.30.0050.00515.49
7.1.20.0060.00615.43
7.1.10.0030.01015.34
7.1.00.0060.01818.83
7.0.330.0060.00315.14
7.0.320.0030.01015.13
7.0.310.0060.00315.25
7.0.300.0000.00914.70
7.0.290.0090.00315.20
7.0.280.0000.01215.09
7.0.270.0090.00015.38
7.0.260.0060.00314.98
7.0.250.0070.00715.38
7.0.240.0000.00915.00
7.0.230.0090.00015.04
7.0.220.0070.00415.27
7.0.210.0070.00415.36
7.0.200.0030.00816.03
7.0.190.0060.00614.89
7.0.180.0070.00314.95
7.0.170.0060.00615.08
7.0.160.0070.00315.01
7.0.150.0080.00315.03
7.0.140.0040.03818.67
7.0.130.0070.00015.21
7.0.120.0030.00714.92
7.0.110.0060.00615.27
7.0.100.0070.00415.26
7.0.90.0000.00815.10
7.0.80.0280.02317.53
7.0.70.0280.02217.62
7.0.60.0220.02817.37
7.0.50.0370.02317.91
7.0.40.0050.02816.58
7.0.30.0080.04716.69
7.0.20.0070.03516.66
7.0.10.0030.02816.72
7.0.00.0050.04416.63
5.6.380.0030.00714.31
5.6.370.0050.00514.02
5.6.360.0040.00413.94
5.6.350.0090.00313.96
5.6.340.0100.00014.03
5.6.330.0100.00714.23
5.6.320.0030.00713.82
5.6.310.0030.00514.41
5.6.300.0040.00414.11
5.6.290.0070.00414.11
5.6.280.0050.04017.71
5.6.270.0040.00713.94
5.6.260.0070.00713.85
5.6.250.0040.00913.73
5.6.240.0070.00713.97
5.6.230.0020.03517.42
5.6.220.0060.02117.39
5.6.210.0000.02617.32
5.6.200.0070.04617.75
5.6.190.0050.04417.56
5.6.180.0080.02917.51
5.6.170.0070.04217.59
5.6.160.0040.04417.61
5.6.150.0100.02717.63
5.6.140.0070.02817.62
5.6.130.0020.03217.54
5.6.120.0020.04817.67
5.6.110.0090.02717.59
5.6.100.0120.03817.46
5.6.90.0060.03817.52
5.6.80.0030.03717.22
5.6.70.0050.02717.11
5.6.60.0070.02417.30
5.6.50.0010.04417.10
5.6.40.0070.02017.31
5.6.30.0050.03417.17
5.6.20.0110.03517.31
5.6.10.0040.04617.22
5.6.00.0070.02917.05
5.5.380.0040.00811.07
5.5.370.0050.02815.63
5.5.360.0030.03215.67
5.5.350.0000.05215.66
5.5.340.0030.03716.09
5.5.330.0050.02415.93
5.5.320.0120.03815.90
5.5.310.0040.04415.87
5.5.300.0070.04115.89
5.5.290.0070.04215.83
5.5.280.0080.03815.77
5.5.270.0080.02815.84
5.5.260.0070.03215.86
5.5.250.0070.03815.77
5.5.240.0030.03915.59
5.5.230.0030.02715.46
5.5.220.0070.04215.58
5.5.210.0090.03115.56
5.5.200.0120.03215.62
5.5.190.0030.02715.56
5.5.180.0060.02315.56
5.5.170.0030.00910.90
5.5.160.0090.03515.54
5.5.150.0020.03815.45
5.5.140.0050.04815.58
5.5.130.0090.03715.52
5.5.120.0030.02915.49
5.5.110.0050.04115.55
5.5.100.0050.03815.49
5.5.90.0120.03015.52
5.5.80.0070.04315.54
5.5.70.0070.03915.53
5.5.60.0090.03915.49
5.5.50.0030.04715.51
5.5.40.0080.03815.52
5.5.30.0030.03115.49
5.5.20.0090.04415.43
5.5.10.0050.02315.44
5.5.00.0050.03815.43
5.4.450.0040.04315.04
5.4.440.0050.04215.18
5.4.430.0080.04015.22
5.4.420.0050.03815.18
5.4.410.0070.03715.11
5.4.400.0090.02015.03
5.4.390.0050.03714.97
5.4.380.0050.03014.97
5.4.370.0090.03015.03
5.4.360.0050.04215.04
5.4.350.0070.03815.00
5.4.340.0020.02814.96
5.4.330.0000.00510.90
5.4.320.0050.02515.01
5.4.310.0100.03314.92
5.4.300.0030.04514.97
5.4.290.0060.03314.97
5.4.280.0050.04315.08
5.4.270.0040.03214.99
5.4.260.0110.01815.02
5.4.250.0040.02614.88
5.4.240.0080.04014.96
5.4.230.0050.03414.96
5.4.220.0050.02515.05
5.4.210.0050.03715.01
5.4.200.0090.03015.05
5.4.190.0080.03714.87
5.4.180.0060.03614.92
5.4.170.0050.03414.97
5.4.160.0100.03714.98
5.4.150.0060.03114.96
5.4.140.0000.03713.71
5.4.130.0050.02813.65
5.4.120.0070.03513.65
5.4.110.0050.03513.71
5.4.100.0030.03813.71
5.4.90.0050.03713.64
5.4.80.0030.04013.66
5.4.70.0060.03613.65
5.4.60.0030.02513.62
5.4.50.0050.02713.59
5.4.40.0060.02613.62
5.4.30.0020.02513.63
5.4.20.0050.01813.69
5.4.10.0030.04013.67
5.4.00.0070.03213.45
5.3.290.0030.02312.83
5.3.280.0100.03512.79
5.3.270.0030.04712.78
5.3.260.0080.03812.73
5.3.250.0100.03512.73
5.3.240.0050.04012.79
5.3.230.0020.05012.72
5.3.220.0030.02312.72
5.3.210.0100.01812.70
5.3.200.0010.02412.71
5.3.190.0020.04212.77
5.3.180.0060.03612.71
5.3.170.0100.03712.73
5.3.160.0060.02012.76
5.3.150.0080.03512.79
5.3.140.0050.02712.80
5.3.130.0050.03312.75
5.3.120.0020.02512.75
5.3.110.0090.03012.79
5.3.100.0060.04012.50
5.3.90.0000.04812.44
5.3.80.0050.04212.47
5.3.70.0020.04212.42
5.3.60.0060.01812.48
5.3.50.0010.04012.44
5.3.40.0050.02712.47
5.3.30.0050.03512.37
5.3.20.0070.03212.29
5.3.10.0030.03812.22
5.3.00.0050.04012.23
5.2.170.0070.02511.04
5.2.160.0060.01511.09
5.2.150.0050.03211.05
5.2.140.0050.02311.03
5.2.130.0030.03011.05
5.2.120.0080.03011.03
5.2.110.0020.03511.03
5.2.100.0030.03311.00
5.2.90.0020.03110.94
5.2.80.0050.02611.00
5.2.70.0030.03210.94
5.2.60.0060.02110.94
5.2.50.0030.02510.90
5.2.40.0080.02711.02
5.2.30.0030.03010.89
5.2.20.0020.02710.94
5.2.10.0050.02710.84
5.2.00.0020.01710.78
5.1.60.0060.02310.72
5.1.50.0050.01610.72
5.1.40.0000.01710.72
5.1.30.0030.02910.72
5.1.20.0030.02410.72
5.1.10.0010.01810.72
5.1.00.0060.02710.72
5.0.50.0040.02510.72
5.0.40.0010.01310.72
5.0.30.0030.03310.72
5.0.20.0020.01710.72
5.0.10.0010.02110.72
5.0.00.0000.03510.72
4.4.90.0000.01910.72
4.4.80.0040.01710.72
4.4.70.0050.00710.72
4.4.60.0060.01410.72
4.4.50.0020.01710.72
4.4.40.0030.01910.72
4.4.30.0000.01410.72
4.4.20.0000.01210.72
4.4.10.0030.01710.72
4.4.00.0020.02710.72
4.3.110.0020.01810.72
4.3.100.0030.00910.72
4.3.90.0050.01510.72
4.3.80.0000.01710.72
4.3.70.0020.01810.72
4.3.60.0040.01510.72
4.3.50.0030.01510.72
4.3.40.0000.01710.72
4.3.30.0000.02210.72
4.3.20.0000.02010.72
4.3.10.0020.01210.72
4.3.00.0020.01110.72

preferences:
32.33 ms | 401 KiB | 5 Q