3v4l.org

run code in 300+ PHP versions simultaneously
<?php function closestDate($day_name){ $day = ucfirst($day_name); if(date('l', time()) == $day_name) return date("Y-m-d", time()); else if(abs(time()-strtotime('next '.$day_name)) < abs(time()-strtotime('last '.$day_name))) return date("Y-m-d", strtotime('next '.$day_name)); else return date("Y-m-d", strtotime('last '.$day_name)); } echo closestDate('Friday');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TbnnN
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'closestdate'
          1        SEND_VAL                                                 'Friday'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function closestdate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 53
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TbnnN
function name:  closestDate
number of ops:  63
compiled vars:  !0 = $day_name, !1 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'ucfirst'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
    5     5        INIT_FCALL                                               'date'
          6        SEND_VAL                                                 'l'
          7        INIT_FCALL                                               'time'
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11        IS_EQUAL                                                 !0, $5
         12      > JMPZ                                                     ~6, ->21
    6    13    >   INIT_FCALL                                               'date'
         14        SEND_VAL                                                 'Y-m-d'
         15        INIT_FCALL                                               'time'
         16        DO_ICALL                                         $7      
         17        SEND_VAR                                                 $7
         18        DO_ICALL                                         $8      
         19      > RETURN                                                   $8
         20*       JMP                                                      ->62
    7    21    >   INIT_FCALL                                               'abs'
         22        INIT_FCALL                                               'time'
         23        DO_ICALL                                         $9      
         24        INIT_FCALL                                               'strtotime'
         25        CONCAT                                           ~10     'next+', !0
         26        SEND_VAL                                                 ~10
         27        DO_ICALL                                         $11     
         28        SUB                                              ~12     $9, $11
         29        SEND_VAL                                                 ~12
         30        DO_ICALL                                         $13     
         31        INIT_FCALL                                               'abs'
         32        INIT_FCALL                                               'time'
         33        DO_ICALL                                         $14     
         34        INIT_FCALL                                               'strtotime'
         35        CONCAT                                           ~15     'last+', !0
         36        SEND_VAL                                                 ~15
         37        DO_ICALL                                         $16     
         38        SUB                                              ~17     $14, $16
         39        SEND_VAL                                                 ~17
         40        DO_ICALL                                         $18     
         41        IS_SMALLER                                               $13, $18
         42      > JMPZ                                                     ~19, ->53
    8    43    >   INIT_FCALL                                               'date'
         44        SEND_VAL                                                 'Y-m-d'
         45        INIT_FCALL                                               'strtotime'
         46        CONCAT                                           ~20     'next+', !0
         47        SEND_VAL                                                 ~20
         48        DO_ICALL                                         $21     
         49        SEND_VAR                                                 $21
         50        DO_ICALL                                         $22     
         51      > RETURN                                                   $22
         52*       JMP                                                      ->62
   10    53    >   INIT_FCALL                                               'date'
         54        SEND_VAL                                                 'Y-m-d'
         55        INIT_FCALL                                               'strtotime'
         56        CONCAT                                           ~23     'last+', !0
         57        SEND_VAL                                                 ~23
         58        DO_ICALL                                         $24     
         59        SEND_VAR                                                 $24
         60        DO_ICALL                                         $25     
         61      > RETURN                                                   $25
   12    62*     > RETURN                                                   null

End of function closestdate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.04 ms | 1403 KiB | 24 Q