3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * ageCheck method * * This is a custom validation method that converts the date of birth into an age and then checks to see if the age falls within the teams level age range * * @param array $check This is the value for date of birth field * @param string $level_id This is the level_id selected for this competitor's team * @return bool */ function ageCheck($check, $level_id) { $dob = array_shift($check); $dob = new DateTime($dob); $today = new DateTime('today'); $age = $dob->diff($today)->y; $age_range = '35-37'; $age_range_arr = explode('-', $age_range); if (stripos($age_range,'N/A') !== false) { return true; } if ($age >= $age_range_arr[0] && $age <= $age_range_arr[1]) { return true; } return 'You must select a date of birth where the competitor\'s age is between ' . $age_range_arr[0] . ' and ' . $age_range_arr[1] . ' years old'; } echo ageCheck(array('dob' => '1978-11-21'), NULL);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vG7oo
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'agecheck'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 null
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function agecheck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 40
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/vG7oo
function name:  ageCheck
number of ops:  48
compiled vars:  !0 = $check, !1 = $level_id, !2 = $dob, !3 = $today, !4 = $age, !5 = $age_range, !6 = $age_range_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        INIT_FCALL                                               'array_shift'
          3        SEND_REF                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !2, $7
   15     6        NEW                                              $9      'DateTime'
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $9
   16    10        NEW                                              $12     'DateTime'
         11        SEND_VAL_EX                                              'today'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !3, $12
   17    14        INIT_METHOD_CALL                                         !2, 'diff'
         15        SEND_VAR_EX                                              !3
         16        DO_FCALL                                      0  $15     
         17        FETCH_OBJ_R                                      ~16     $15, 'y'
         18        ASSIGN                                                   !4, ~16
   19    19        ASSIGN                                                   !5, '35-37'
   20    20        INIT_FCALL                                               'explode'
         21        SEND_VAL                                                 '-'
         22        SEND_VAR                                                 !5
         23        DO_ICALL                                         $19     
         24        ASSIGN                                                   !6, $19
   22    25        INIT_FCALL                                               'stripos'
         26        SEND_VAR                                                 !5
         27        SEND_VAL                                                 'N%2FA'
         28        DO_ICALL                                         $21     
         29        TYPE_CHECK                                  1018          $21
         30      > JMPZ                                                     ~22, ->32
         31    > > RETURN                                                   <true>
   24    32    >   FETCH_DIM_R                                      ~23     !6, 0
         33        IS_SMALLER_OR_EQUAL                              ~24     ~23, !4
         34      > JMPZ_EX                                          ~24     ~24, ->38
         35    >   FETCH_DIM_R                                      ~25     !6, 1
         36        IS_SMALLER_OR_EQUAL                              ~26     !4, ~25
         37        BOOL                                             ~24     ~26
         38    > > JMPZ                                                     ~24, ->40
   25    39    > > RETURN                                                   <true>
   28    40    >   FETCH_DIM_R                                      ~27     !6, 0
         41        CONCAT                                           ~28     'You+must+select+a+date+of+birth+where+the+competitor%27s+age+is+between+', ~27
         42        CONCAT                                           ~29     ~28, '+and+'
         43        FETCH_DIM_R                                      ~30     !6, 1
         44        CONCAT                                           ~31     ~29, ~30
         45        CONCAT                                           ~32     ~31, '+years+old'
         46      > RETURN                                                   ~32
   29    47*     > RETURN                                                   null

End of function agecheck

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.69 ms | 1403 KiB | 20 Q