3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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; } ?>
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/YZClc on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/YZClc on line 15
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/YZClc on line 15
Process exited with code 255.