3v4l.org

run code in 300+ PHP versions simultaneously
<style type="text/css"> .calculator_table { font-size:12px; font-family:Century Gothic; border:2pt solid #000000; background-color:#6BB3FF padding:25px; width:300px; } </style> <?php if(!empty($_POST['calculator_ok'])): //last cycle date $date="$_POST[dateyear]-$_POST[datemonth]-$_POST[dateday]"; //convert to time $lasttime=mktime(0,0,0,$_POST['datemonth'],$_POST['dateday'],$_POST['dateyear']); // next period start $next_period=$lasttime + $_POST['days']*24*3600; $next_period=date("F d, Y",$next_period); //first fertile day $firstdaytime=$lasttime + $_POST['days']*24*3600 - 16*24*3600; $firstday=date("F d, Y",$firstdaytime); //last fertile day $lastdaytime=$lasttime + $_POST['days']*24*3600 - 12*24*3600; $lastday=date("F d, Y",$lastdaytime); //have to adjust due date? $diff=$_POST['days'] - 28; //due date $date + 280 days $duedatetime=$lasttime + 280*24*3600 + $diff*24*3600; $duedate=date("F d, Y",$duedatetime); ?> <div class="calculator_table"> <p>Here are the results based on the information you provided:</p> <p>Your next <b>menstrual period</b> is expected to start on <strong><?php echo $next_period?></strong>.</p> <p>You next <b>most fertile</b> period is <strong><?php echo $firstday?> to <?php echo $lastday?></strong>.</p> <p>If you conceive within this timeframe, your estimated <b>due date</b> will be <strong><?php echo $duedate?></strong>.</p> <p align="center"><input type="button" value="Calculate again!" onclick="window.location='http://<?php echo $_SERVER['HTTP_HOST'];?><?php echo $_SERVER['REQUEST_URI']?>'"></p> </div> <?php else: //the calculator comes here ?> <div class="calculator_table"> <form method="post"> <p>Please select the first day of your last menstrual period:</p> <p><?php echo date_chooser("date",date("Y-m-d"))?></p> <p>Usual number of days in your period: <select name="days"> <?php for($i=20;$i<=45;$i++) { if($i==28) $selected='selected="true"'; else $selected=''; echo "<option $selected value='$i'>$i</option>"; } ?> </select></p> <p align="center"><input type="submit" name="calculator_ok" value="Calculate"></p> </form> </div> <?php endif; //to print a date chooser - get name and value in mysql date format function date_chooser($name,$value="") { $months=array('','January','February','March','April','May','June','July','August', 'September','October','November','December'); if(empty($value)) $value=date("Y-m-d"); $parts=explode("-",$value); $day=$parts[2]+0; $month=$parts[1]+0; $year=$parts[0]; $chooser=""; $chooser.="<select name='".$name."month'>"; for($i=1;$i<=12;$i++) { if($i==$month) $selected='selected="true"'; else $selected=''; $chooser.="<option $selected value='$i'>$months[$i]</option>"; } $chooser.="</select> / "; $chooser.="<select name='".$name."day'>"; for($i=1;$i<=31;$i++) { if($i==$day) $selected='selected'; else $selected=''; $chooser.="<option $selected value='$i'>$i</option>"; } $chooser.="</select> / "; $chooser.="<select name='".$name."year'>"; for($i=(date("Y")-1);$i<=2050;$i++) { if($i==$year) $selected='selected'; else $selected=''; $chooser.="<option $selected>$i</option>"; } $chooser.="</select> "; return $chooser; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 98
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 127
Branch analysis from position: 127
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 98
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
2 jumps found. (Code = 44) Position 1 = 126, Position 2 = 110
Branch analysis from position: 126
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 110
2 jumps found. (Code = 43) Position 1 = 112, Position 2 = 114
Branch analysis from position: 112
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
2 jumps found. (Code = 44) Position 1 = 126, Position 2 = 110
Branch analysis from position: 126
Branch analysis from position: 110
Branch analysis from position: 114
2 jumps found. (Code = 44) Position 1 = 126, Position 2 = 110
Branch analysis from position: 126
Branch analysis from position: 110
filename:       /in/ZjP0Z
function name:  (null)
number of ops:  128
compiled vars:  !0 = $date, !1 = $lasttime, !2 = $next_period, !3 = $firstdaytime, !4 = $firstday, !5 = $lastdaytime, !6 = $lastday, !7 = $diff, !8 = $duedatetime, !9 = $duedate, !10 = $i, !11 = $selected
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3Cstyle+type%3D%22text%2Fcss%22%3E%0A.calculator_table%0A%7B%0A%09font-size%3A12px%3B%0A%09font-family%3ACentury+Gothic%3B%0A%09border%3A2pt+solid+%23000000%3B%0A%09background-color%3A%236BB3FF%0A%09padding%3A25px%3B%0A%09width%3A300px%3B%09%0A%7D%0A%3C%2Fstyle%3E%0A'
   12     1        FETCH_IS                                         ~12     '_POST'
          2        ISSET_ISEMPTY_DIM_OBJ                         1  ~13     ~12, 'calculator_ok'
          3        BOOL_NOT                                         ~14     ~13
          4      > JMPZ                                                     ~14, ->98
   14     5    >   FETCH_R                      global              ~15     '_POST'
          6        FETCH_DIM_R                                      ~16     ~15, 'dateyear'
          7        ROPE_INIT                                     5  ~22     ~16
          8        ROPE_ADD                                      1  ~22     ~22, '-'
          9        FETCH_R                      global              ~17     '_POST'
         10        FETCH_DIM_R                                      ~18     ~17, 'datemonth'
         11        ROPE_ADD                                      2  ~22     ~22, ~18
         12        ROPE_ADD                                      3  ~22     ~22, '-'
         13        FETCH_R                      global              ~19     '_POST'
         14        FETCH_DIM_R                                      ~20     ~19, 'dateday'
         15        ROPE_END                                      4  ~21     ~22, ~20
         16        ASSIGN                                                   !0, ~21
   17    17        INIT_FCALL                                               'mktime'
         18        SEND_VAL                                                 0
         19        SEND_VAL                                                 0
         20        SEND_VAL                                                 0
         21        FETCH_R                      global              ~26     '_POST'
         22        FETCH_DIM_R                                      ~27     ~26, 'datemonth'
         23        SEND_VAL                                                 ~27
         24        FETCH_R                      global              ~28     '_POST'
         25        FETCH_DIM_R                                      ~29     ~28, 'dateday'
         26        SEND_VAL                                                 ~29
         27        FETCH_R                      global              ~30     '_POST'
         28        FETCH_DIM_R                                      ~31     ~30, 'dateyear'
         29        SEND_VAL                                                 ~31
         30        DO_ICALL                                         $32     
         31        ASSIGN                                                   !1, $32
   20    32        FETCH_R                      global              ~34     '_POST'
         33        FETCH_DIM_R                                      ~35     ~34, 'days'
         34        MUL                                              ~36     ~35, 24
         35        MUL                                              ~37     ~36, 3600
         36        ADD                                              ~38     !1, ~37
         37        ASSIGN                                                   !2, ~38
   21    38        INIT_FCALL                                               'date'
         39        SEND_VAL                                                 'F+d%2C+Y'
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $40     
         42        ASSIGN                                                   !2, $40
   24    43        FETCH_R                      global              ~42     '_POST'
         44        FETCH_DIM_R                                      ~43     ~42, 'days'
         45        MUL                                              ~44     ~43, 24
         46        MUL                                              ~45     ~44, 3600
         47        ADD                                              ~46     !1, ~45
         48        SUB                                              ~47     ~46, 1382400
         49        ASSIGN                                                   !3, ~47
   25    50        INIT_FCALL                                               'date'
         51        SEND_VAL                                                 'F+d%2C+Y'
         52        SEND_VAR                                                 !3
         53        DO_ICALL                                         $49     
         54        ASSIGN                                                   !4, $49
   28    55        FETCH_R                      global              ~51     '_POST'
         56        FETCH_DIM_R                                      ~52     ~51, 'days'
         57        MUL                                              ~53     ~52, 24
         58        MUL                                              ~54     ~53, 3600
         59        ADD                                              ~55     !1, ~54
         60        SUB                                              ~56     ~55, 1036800
         61        ASSIGN                                                   !5, ~56
   29    62        INIT_FCALL                                               'date'
         63        SEND_VAL                                                 'F+d%2C+Y'
         64        SEND_VAR                                                 !5
         65        DO_ICALL                                         $58     
         66        ASSIGN                                                   !6, $58
   32    67        FETCH_R                      global              ~60     '_POST'
         68        FETCH_DIM_R                                      ~61     ~60, 'days'
         69        SUB                                              ~62     ~61, 28
         70        ASSIGN                                                   !7, ~62
   35    71        ADD                                              ~64     !1, 24192000
         72        MUL                                              ~65     !7, 24
         73        MUL                                              ~66     ~65, 3600
         74        ADD                                              ~67     ~64, ~66
         75        ASSIGN                                                   !8, ~67
   36    76        INIT_FCALL                                               'date'
         77        SEND_VAL                                                 'F+d%2C+Y'
         78        SEND_VAR                                                 !8
         79        DO_ICALL                                         $69     
         80        ASSIGN                                                   !9, $69
   39    81        ECHO                                                     '%09%3Cdiv+class%3D%22calculator_table%22%3E%0A%09%3Cp%3EHere+are+the+results+based+on+the+information+you+provided%3A%3C%2Fp%3E%0A++++%3Cp%3EYour+next+%3Cb%3Emenstrual+period%3C%2Fb%3E+is+expected+to+start+on+%3Cstrong%3E'
   41    82        ECHO                                                     !2
         83        ECHO                                                     '%3C%2Fstrong%3E.%3C%2Fp%3E%0A%09%3Cp%3EYou+next+%3Cb%3Emost+fertile%3C%2Fb%3E+period+is+%3Cstrong%3E'
   42    84        ECHO                                                     !4
         85        ECHO                                                     '+to+'
         86        ECHO                                                     !6
         87        ECHO                                                     '%3C%2Fstrong%3E.%3C%2Fp%3E%0A%09%3Cp%3EIf+you+conceive+within+this+timeframe%2C+your+estimated+%3Cb%3Edue+date%3C%2Fb%3E+will+be+%3Cstrong%3E'
   43    88        ECHO                                                     !9
         89        ECHO                                                     '%3C%2Fstrong%3E.%3C%2Fp%3E%0A%09%3Cp+align%3D%22center%22%3E%3Cinput+type%3D%22button%22+value%3D%22Calculate+again%21%22+onclick%3D%22window.location%3D%27http%3A%2F%2F'
   44    90        FETCH_R                      global              ~71     '_SERVER'
         91        FETCH_DIM_R                                      ~72     ~71, 'HTTP_HOST'
         92        ECHO                                                     ~72
         93        FETCH_R                      global              ~73     '_SERVER'
         94        FETCH_DIM_R                                      ~74     ~73, 'REQUEST_URI'
         95        ECHO                                                     ~74
         96        ECHO                                                     '%27%22%3E%3C%2Fp%3E%0A%09%3C%2Fdiv%3E%0A'
         97      > JMP                                                      ->127
   49    98    >   ECHO                                                     '%09%3Cdiv+class%3D%22calculator_table%22%3E%0A%09%3Cform+method%3D%22post%22%3E%0A%09%3Cp%3EPlease+select+the+first+day+of+your+last+menstrual+period%3A%3C%2Fp%3E%0A%09%3Cp%3E'
   52    99        INIT_FCALL_BY_NAME                                       'date_chooser'
        100        SEND_VAL_EX                                              'date'
        101        INIT_FCALL                                               'date'
        102        SEND_VAL                                                 'Y-m-d'
        103        DO_ICALL                                         $75     
        104        SEND_VAR_NO_REF_EX                                       $75
        105        DO_FCALL                                      0  $76     
        106        ECHO                                                     $76
        107        ECHO                                                     '%3C%2Fp%3E%0A%09%3Cp%3EUsual+number+of+days+in+your+period%3A+%3Cselect+name%3D%22days%22%3E%0A%09'
   55   108        ASSIGN                                                   !10, 20
        109      > JMP                                                      ->124
   57   110    >   IS_EQUAL                                                 !10, 28
        111      > JMPZ                                                     ~78, ->114
        112    >   ASSIGN                                                   !11, 'selected%3D%22true%22'
        113      > JMP                                                      ->115
   58   114    >   ASSIGN                                                   !11, ''
   59   115    >   ROPE_INIT                                     7  ~82     '%3Coption+'
        116        ROPE_ADD                                      1  ~82     ~82, !11
        117        ROPE_ADD                                      2  ~82     ~82, '+value%3D%27'
        118        ROPE_ADD                                      3  ~82     ~82, !10
        119        ROPE_ADD                                      4  ~82     ~82, '%27%3E'
        120        ROPE_ADD                                      5  ~82     ~82, !10
        121        ROPE_END                                      6  ~81     ~82, '%3C%2Foption%3E'
        122        ECHO                                                     ~81
   55   123        PRE_INC                                                  !10
        124    >   IS_SMALLER_OR_EQUAL                                      !10, 45
        125      > JMPNZ                                                    ~87, ->110
   62   126    >   ECHO                                                     '%09%3C%2Fselect%3E%3C%2Fp%3E%0A%09%3Cp+align%3D%22center%22%3E%3Cinput+type%3D%22submit%22+name%3D%22calculator_ok%22+value%3D%22Calculate%22%3E%3C%2Fp%3E%0A%09%3C%2Fform%3E%0A%09%3C%2Fdiv%3E%0A'
  113   127    > > RETURN                                                   1

Function date_chooser:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 28
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 51
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 77
Branch analysis from position: 91
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 81
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 77
Branch analysis from position: 91
Branch analysis from position: 77
Branch analysis from position: 81
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 77
Branch analysis from position: 91
Branch analysis from position: 77
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 55
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 51
Branch analysis from position: 67
Branch analysis from position: 51
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 51
Branch analysis from position: 67
Branch analysis from position: 51
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 28
Branch analysis from position: 45
Branch analysis from position: 28
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 28
Branch analysis from position: 45
Branch analysis from position: 28
Branch analysis from position: 9
filename:       /in/ZjP0Z
function name:  date_chooser
number of ops:  94
compiled vars:  !0 = $name, !1 = $value, !2 = $months, !3 = $parts, !4 = $day, !5 = $month, !6 = $year, !7 = $chooser, !8 = $i, !9 = $selected
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
   71     2        ASSIGN                                                   !2, <array>
   74     3        ISSET_ISEMPTY_CV                                         !1
          4      > JMPZ                                                     ~11, ->9
          5    >   INIT_FCALL                                               'date'
          6        SEND_VAL                                                 'Y-m-d'
          7        DO_ICALL                                         $12     
          8        ASSIGN                                                   !1, $12
   76     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '-'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $14     
         13        ASSIGN                                                   !3, $14
   78    14        FETCH_DIM_R                                      ~16     !3, 2
         15        ADD                                              ~17     ~16, 0
         16        ASSIGN                                                   !4, ~17
   79    17        FETCH_DIM_R                                      ~19     !3, 1
         18        ADD                                              ~20     ~19, 0
         19        ASSIGN                                                   !5, ~20
   80    20        FETCH_DIM_R                                      ~22     !3, 0
         21        ASSIGN                                                   !6, ~22
   82    22        ASSIGN                                                   !7, ''
   84    23        CONCAT                                           ~25     '%3Cselect+name%3D%27', !0
         24        CONCAT                                           ~26     ~25, 'month%27%3E'
         25        ASSIGN_OP                                     8          !7, ~26
   85    26        ASSIGN                                                   !8, 1
         27      > JMP                                                      ->43
   87    28    >   IS_EQUAL                                                 !8, !5
         29      > JMPZ                                                     ~29, ->32
         30    >   ASSIGN                                                   !9, 'selected%3D%22true%22'
         31      > JMP                                                      ->33
   88    32    >   ASSIGN                                                   !9, ''
   89    33    >   ROPE_INIT                                     7  ~34     '%3Coption+'
         34        ROPE_ADD                                      1  ~34     ~34, !9
         35        ROPE_ADD                                      2  ~34     ~34, '+value%3D%27'
         36        ROPE_ADD                                      3  ~34     ~34, !8
         37        ROPE_ADD                                      4  ~34     ~34, '%27%3E'
         38        FETCH_DIM_R                                      ~32     !2, !8
         39        ROPE_ADD                                      5  ~34     ~34, ~32
         40        ROPE_END                                      6  ~33     ~34, '%3C%2Foption%3E'
         41        ASSIGN_OP                                     8          !7, ~33
   85    42        PRE_INC                                                  !8
         43    >   IS_SMALLER_OR_EQUAL                                      !8, 12
         44      > JMPNZ                                                    ~40, ->28
   91    45    >   ASSIGN_OP                                     8          !7, '%3C%2Fselect%3E+%2F+'
   93    46        CONCAT                                           ~42     '%3Cselect+name%3D%27', !0
         47        CONCAT                                           ~43     ~42, 'day%27%3E'
         48        ASSIGN_OP                                     8          !7, ~43
   94    49        ASSIGN                                                   !8, 1
         50      > JMP                                                      ->65
   96    51    >   IS_EQUAL                                                 !8, !4
         52      > JMPZ                                                     ~46, ->55
         53    >   ASSIGN                                                   !9, 'selected'
         54      > JMP                                                      ->56
   97    55    >   ASSIGN                                                   !9, ''
   98    56    >   ROPE_INIT                                     7  ~50     '%3Coption+'
         57        ROPE_ADD                                      1  ~50     ~50, !9
         58        ROPE_ADD                                      2  ~50     ~50, '+value%3D%27'
         59        ROPE_ADD                                      3  ~50     ~50, !8
         60        ROPE_ADD                                      4  ~50     ~50, '%27%3E'
         61        ROPE_ADD                                      5  ~50     ~50, !8
         62        ROPE_END                                      6  ~49     ~50, '%3C%2Foption%3E'
         63        ASSIGN_OP                                     8          !7, ~49
   94    64        PRE_INC                                                  !8
         65    >   IS_SMALLER_OR_EQUAL                                      !8, 31
         66      > JMPNZ                                                    ~56, ->51
  100    67    >   ASSIGN_OP                                     8          !7, '%3C%2Fselect%3E+%2F+'
  102    68        CONCAT                                           ~58     '%3Cselect+name%3D%27', !0
         69        CONCAT                                           ~59     ~58, 'year%27%3E'
         70        ASSIGN_OP                                     8          !7, ~59
  103    71        INIT_FCALL                                               'date'
         72        SEND_VAL                                                 'Y'
         73        DO_ICALL                                         $61     
         74        SUB                                              ~62     $61, 1
         75        ASSIGN                                                   !8, ~62
         76      > JMP                                                      ->89
  105    77    >   IS_EQUAL                                                 !8, !6
         78      > JMPZ                                                     ~64, ->81
         79    >   ASSIGN                                                   !9, 'selected'
         80      > JMP                                                      ->82
  106    81    >   ASSIGN                                                   !9, ''
  107    82    >   ROPE_INIT                                     5  ~68     '%3Coption+'
         83        ROPE_ADD                                      1  ~68     ~68, !9
         84        ROPE_ADD                                      2  ~68     ~68, '%3E'
         85        ROPE_ADD                                      3  ~68     ~68, !8
         86        ROPE_END                                      4  ~67     ~68, '%3C%2Foption%3E'
         87        ASSIGN_OP                                     8          !7, ~67
  103    88        PRE_INC                                                  !8
         89    >   IS_SMALLER_OR_EQUAL                                      !8, 2050
         90      > JMPNZ                                                    ~73, ->77
  109    91    >   ASSIGN_OP                                     8          !7, '%3C%2Fselect%3E+'
  111    92      > RETURN                                                   !7
  112    93*     > RETURN                                                   null

End of function date_chooser

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.25 ms | 1421 KiB | 19 Q