3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Check if a given date is the first Monday of the month * * @param \DateTime $date * @return bool */ function isFirstMondayayOfMonth(\DateTime $date) { return (int)$date->format('d') <= 7 && $date->format('l') === 'Monday'; } $day = new \DateTime('2014/3/7'); var_dump(isFirstMondayayOfMonth($day)); $day = new \DateTime('2013/10/2'); var_dump(isFirstMondayayOfMonth($day));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6789q
function name:  (null)
number of ops:  21
compiled vars:  !0 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $1      'DateTime'
          1        SEND_VAL_EX                                              '2014%2F3%2F7'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   14     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'isfirstmondayayofmonth'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   16    10        NEW                                              $6      'DateTime'
         11        SEND_VAL_EX                                              '2013%2F10%2F2'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $6
   17    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'isfirstmondayayofmonth'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function isfirstmondayayofmonth:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/6789q
function name:  isFirstMondayayOfMonth
number of ops:  14
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_METHOD_CALL                                         !0, 'format'
          2        SEND_VAL_EX                                              'd'
          3        DO_FCALL                                      0  $1      
          4        CAST                                          4  ~2      $1
          5        IS_SMALLER_OR_EQUAL                              ~3      ~2, 7
          6      > JMPZ_EX                                          ~3      ~3, ->12
          7    >   INIT_METHOD_CALL                                         !0, 'format'
          8        SEND_VAL_EX                                              'l'
          9        DO_FCALL                                      0  $4      
         10        IS_IDENTICAL                                     ~5      $4, 'Monday'
         11        BOOL                                             ~3      ~5
         12    > > RETURN                                                   ~3
   11    13*     > RETURN                                                   null

End of function isfirstmondayayofmonth

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.3 ms | 1399 KiB | 17 Q