3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* draws a calendar */ function draw_calendar($month,$year){ /* draw table */ $calendar = '<table cellpadding="0" cellspacing="0" class="calendar">'; /* table headings */ $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>'; /* days and weeks vars now ... */ $running_day = date('w',mktime(0,0,0,$month,1,$year)); $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); $days_in_this_week = 1; $day_counter = 0; $dates_array = array(); /* row for week one */ $calendar.= '<tr class="calendar-row">'; /* print "blank" days until the first of the current week */ for($x = 0; $x < $running_day; $x++): $calendar.= '<td class="calendar-day-np"> </td>'; $days_in_this_week++; endfor; /* keep going with days.... */ for($list_day = 1; $list_day <= $days_in_month; $list_day++): $calendar.= '<td class="calendar-day">'; /* add in the day number */ $calendar.= '<div class="day-number">'.$list_day.'</div>'; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $calendar.= str_repeat('<p> </p>',2); $calendar.= '</td>'; if($running_day == 6): $calendar.= '</tr>'; if(($day_counter+1) != $days_in_month): $calendar.= '<tr class="calendar-row">'; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; /* finish the rest of the days in the week */ if($days_in_this_week < 8): for($x = 1; $x <= (8 - $days_in_this_week); $x++): $calendar.= '<td class="calendar-day-np"> </td>'; endfor; endif; /* final row */ $calendar.= '</tr>'; /* end the table */ $calendar.= '</table>'; /* all done, return result */ return $calendar; } /* sample usages */ echo '<h2>July 2009</h2>'; echo draw_calendar(7,2009); echo '<h2>August 2009</h2>'; echo draw_calendar(8,2009); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4efDN
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   ECHO                                                     '%3Ch2%3EJuly+2009%3C%2Fh2%3E'
   68     1        INIT_FCALL                                               'draw_calendar'
          2        SEND_VAL                                                 7
          3        SEND_VAL                                                 2009
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
   70     6        ECHO                                                     '%3Ch2%3EAugust+2009%3C%2Fh2%3E'
   71     7        INIT_FCALL                                               'draw_calendar'
          8        SEND_VAL                                                 8
          9        SEND_VAL                                                 2009
         10        DO_FCALL                                      0  $1      
         11        ECHO                                                     $1
   72    12      > RETURN                                                   1

Function draw_calendar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 43
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 50
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 84
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
2 jumps found. (Code = 44) Position 1 = 84, Position 2 = 79
Branch analysis from position: 84
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
2 jumps found. (Code = 44) Position 1 = 84, Position 2 = 79
Branch analysis from position: 84
Branch analysis from position: 79
Branch analysis from position: 84
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 69
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 67
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 50
Branch analysis from position: 75
Branch analysis from position: 50
Branch analysis from position: 67
Branch analysis from position: 69
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 43
Branch analysis from position: 48
Branch analysis from position: 43
filename:       /in/4efDN
function name:  draw_calendar
number of ops:  88
compiled vars:  !0 = $month, !1 = $year, !2 = $calendar, !3 = $headings, !4 = $running_day, !5 = $days_in_month, !6 = $days_in_this_week, !7 = $day_counter, !8 = $dates_array, !9 = $x, !10 = $list_day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ASSIGN                                                   !2, '%3Ctable+cellpadding%3D%220%22+cellspacing%3D%220%22+class%3D%22calendar%22%3E'
    9     3        ASSIGN                                                   !3, <array>
   10     4        INIT_FCALL                                               'implode'
          5        SEND_VAL                                                 '%3C%2Ftd%3E%3Ctd+class%3D%22calendar-day-head%22%3E'
          6        SEND_VAR                                                 !3
          7        DO_ICALL                                         $13     
          8        CONCAT                                           ~14     '%3Ctr+class%3D%22calendar-row%22%3E%3Ctd+class%3D%22calendar-day-head%22%3E', $13
          9        CONCAT                                           ~15     ~14, '%3C%2Ftd%3E%3C%2Ftr%3E'
         10        ASSIGN_OP                                     8          !2, ~15
   13    11        INIT_FCALL                                               'date'
         12        SEND_VAL                                                 'w'
         13        INIT_FCALL                                               'mktime'
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 0
         16        SEND_VAL                                                 0
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 1
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $17     
         21        SEND_VAR                                                 $17
         22        DO_ICALL                                         $18     
         23        ASSIGN                                                   !4, $18
   14    24        INIT_FCALL                                               'date'
         25        SEND_VAL                                                 't'
         26        INIT_FCALL                                               'mktime'
         27        SEND_VAL                                                 0
         28        SEND_VAL                                                 0
         29        SEND_VAL                                                 0
         30        SEND_VAR                                                 !0
         31        SEND_VAL                                                 1
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                         $20     
         34        SEND_VAR                                                 $20
         35        DO_ICALL                                         $21     
         36        ASSIGN                                                   !5, $21
   15    37        ASSIGN                                                   !6, 1
   16    38        ASSIGN                                                   !7, 0
   17    39        ASSIGN                                                   !8, <array>
   20    40        ASSIGN_OP                                     8          !2, '%3Ctr+class%3D%22calendar-row%22%3E'
   23    41        ASSIGN                                                   !9, 0
         42      > JMP                                                      ->46
   24    43    >   ASSIGN_OP                                     8          !2, '%3Ctd+class%3D%22calendar-day-np%22%3E+%3C%2Ftd%3E'
   25    44        PRE_INC                                                  !6
   23    45        PRE_INC                                                  !9
         46    >   IS_SMALLER                                               !9, !4
         47      > JMPNZ                                                    ~31, ->43
   29    48    >   ASSIGN                                                   !10, 1
         49      > JMP                                                      ->73
   30    50    >   ASSIGN_OP                                     8          !2, '%3Ctd+class%3D%22calendar-day%22%3E'
   32    51        CONCAT                                           ~34     '%3Cdiv+class%3D%22day-number%22%3E', !10
         52        CONCAT                                           ~35     ~34, '%3C%2Fdiv%3E'
         53        ASSIGN_OP                                     8          !2, ~35
   35    54        INIT_FCALL                                               'str_repeat'
         55        SEND_VAL                                                 '%3Cp%3E+%3C%2Fp%3E'
         56        SEND_VAL                                                 2
         57        DO_ICALL                                         $37     
         58        ASSIGN_OP                                     8          !2, $37
   37    59        ASSIGN_OP                                     8          !2, '%3C%2Ftd%3E'
   38    60        IS_EQUAL                                                 !4, 6
         61      > JMPZ                                                     ~40, ->69
   39    62    >   ASSIGN_OP                                     8          !2, '%3C%2Ftr%3E'
   40    63        ADD                                              ~42     !7, 1
         64        IS_NOT_EQUAL                                             !5, ~42
         65      > JMPZ                                                     ~43, ->67
   41    66    >   ASSIGN_OP                                     8          !2, '%3Ctr+class%3D%22calendar-row%22%3E'
   43    67    >   ASSIGN                                                   !4, -1
   44    68        ASSIGN                                                   !6, 0
   46    69    >   PRE_INC                                                  !6
         70        PRE_INC                                                  !4
         71        PRE_INC                                                  !7
   29    72        PRE_INC                                                  !10
         73    >   IS_SMALLER_OR_EQUAL                                      !10, !5
         74      > JMPNZ                                                    ~51, ->50
   50    75    >   IS_SMALLER                                               !6, 8
         76      > JMPZ                                                     ~52, ->84
   51    77    >   ASSIGN                                                   !9, 1
         78      > JMP                                                      ->81
   52    79    >   ASSIGN_OP                                     8          !2, '%3Ctd+class%3D%22calendar-day-np%22%3E+%3C%2Ftd%3E'
   51    80        PRE_INC                                                  !9
         81    >   SUB                                              ~56     8, !6
         82        IS_SMALLER_OR_EQUAL                                      !9, ~56
         83      > JMPNZ                                                    ~57, ->79
   57    84    >   ASSIGN_OP                                     8          !2, '%3C%2Ftr%3E'
   60    85        ASSIGN_OP                                     8          !2, '%3C%2Ftable%3E'
   63    86      > RETURN                                                   !2
   64    87*     > RETURN                                                   null

End of function draw_calendar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.07 ms | 1407 KiB | 23 Q