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 = array( '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 = array( 'post_count' => $num_posts, 'expiry_date' => strtotime( 'tomorrow' ), ); update_user_meta($user_id, $key, $values); return $activity_value; } return 0; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YvXpu
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E > > RETURN                                                   1

Function restrict_posting_points:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 46
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 61
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 33
filename:       /in/YvXpu
function name:  restrict_posting_points
number of ops:  63
compiled vars:  !0 = $user_id, !1 = $activity_value, !2 = $activity_id, !3 = $activity_type, !4 = $max_posts_per_day, !5 = $key, !6 = $single, !7 = $daily_post_count, !8 = $values, !9 = $num_posts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    4     4        ASSIGN                                                   !4, 2
    6     5        ASSIGN                                                   !0, !0
    7     6        ASSIGN                                                   !5, 'daily_post_count'
    8     7        ASSIGN                                                   !6, <true>
   10     8        INIT_FCALL_BY_NAME                                       'get_user_meta'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAR_EX                                              !5
         11        SEND_VAR_EX                                              !6
         12        DO_FCALL                                      0  $14     
         13        ASSIGN                                                   !7, $14
   14    14        IS_EQUAL                                                 !7, ''
         15      > JMPZ                                                     ~16, ->33
   16    16    >   INIT_ARRAY                                       ~17     0, 'post_count'
   17    17        INIT_FCALL                                               'strtotime'
         18        SEND_VAL                                                 'tomorrow'
         19        DO_ICALL                                         $18     
         20        ADD_ARRAY_ELEMENT                                ~17     $18, 'expiry_date'
   15    21        ASSIGN                                                   !8, ~17
   19    22        INIT_FCALL_BY_NAME                                       'add_user_meta'
         23        SEND_VAR_EX                                              !0
         24        SEND_VAR_EX                                              !5
         25        SEND_VAR_EX                                              !8
         26        DO_FCALL                                      0          
   20    27        INIT_FCALL_BY_NAME                                       'get_user_meta'
         28        SEND_VAR_EX                                              !0
         29        SEND_VAR_EX                                              !5
         30        SEND_VAR_EX                                              !6
         31        DO_FCALL                                      0  $21     
         32        ASSIGN                                                   !7, $21
   23    33    >   FETCH_DIM_R                                      ~23     !7, 'post_count'
         34        ASSIGN                                                   !9, ~23
   26    35        INIT_FCALL                                               'time'
         36        DO_ICALL                                         $25     
         37        FETCH_DIM_R                                      ~26     !7, 'expiry_date'
         38        IS_SMALLER                                               ~26, $25
         39      > JMPZ                                                     ~27, ->46
   27    40    >   ASSIGN                                                   !9, 0
   28    41        INIT_FCALL                                               'strtotime'
         42        SEND_VAL                                                 'tomorrow'
         43        DO_ICALL                                         $30     
         44        ASSIGN_DIM                                               !7, 'expiry_date'
         45        OP_DATA                                                  $30
   32    46    >   IS_SMALLER                                               !9, !4
         47      > JMPZ                                                     ~31, ->61
   33    48    >   PRE_INC                                                  !9
   36    49        INIT_ARRAY                                       ~33     !9, 'post_count'
   37    50        INIT_FCALL                                               'strtotime'
         51        SEND_VAL                                                 'tomorrow'
         52        DO_ICALL                                         $34     
         53        ADD_ARRAY_ELEMENT                                ~33     $34, 'expiry_date'
   35    54        ASSIGN                                                   !8, ~33
   39    55        INIT_FCALL_BY_NAME                                       'update_user_meta'
         56        SEND_VAR_EX                                              !0
         57        SEND_VAR_EX                                              !5
         58        SEND_VAR_EX                                              !8
         59        DO_FCALL                                      0          
   41    60      > RETURN                                                   !1
   44    61    > > RETURN                                                   0
   45    62*     > RETURN                                                   null

End of function restrict_posting_points

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.96 ms | 1400 KiB | 17 Q