javascript - PHP build_calendar not displaying table

one text

I am trying to use the build_calendar() function on PHP to display a simple calendar but when I run the following code I don??�t get any error messages but I just get a blank page.

I??�m not sure where I went wrong. Do I need to add a MySQL database first? I am running this using XAMPP on a Mac on Google Chrome

<?php
    function build_calendar($month, $year){
        
        $daysOfWeek = array('Sunday', 'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
question?
$firstDayOfMonth = mktime(0,0,0,$month,1,$year);

$numberDays = date('t',$firstDayOfMonth);

$dateComponents = getdate($firstDayOfMonth);

$monthName = $dateComponents['month'];

$dayOfWeek = $dateComponents['wday'];

$datetoday = date('Y-m-d'); 
$calendar = "<table class='table table-bordered'>"; 
$calendar .= "<center><h2>$monthName $year</h2>"; 
$calendar .= "<tr>"; 
foreach($daysOfWeek as $day) { 
     $calendar .= "<th class='header'>$day</th>"; 
} 

$currentDay = 1;
$calendar .= "</tr><tr>";

if($dayOfWeek > 0) { 
    for($k=0;$k<$dayOfWeek;$k++){ 
        $calendar .= "<td class='empty'></td>"; 
    } 
}
$month = str_pad($month, 2, "0", STR_PAD_LEFT);
while ($currentDay <= $numberDays) { 

    if ($dayOfWeek == 7) { 
        $dayOfWeek = 0; 
        $calendar .= "</tr><tr>"; 
    } 
    $currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT); 
    $date = "$year-$month-$currentDayRel"; 
    $dayname = strtolower(date('l', strtotime($date))); 
    $eventNum = 0; 
    $today = $date==date('Y-m-d')? "today" : "";
    $calendar.="<td><h4>$currentDay</h4>"; 
    $calendar .="</td>"; 

    $currentDay++; 
    $dayOfWeek++; 
} 

if ($dayOfWeek != 7) { 
    $remainingDays = 7 - $dayOfWeek; 
    for($l=0;$l<$remainingDays;$l++){ 
        $calendar .= "<td class='empty'></td>"; 
    } 
} 

$calendar .= "</tr>"; 
$calendar .= "</table>";

    }
?>

<!DOCTYPE html>
 <html>
 <body> 
 <div class="container"> 
  <div class="row"> 
   <div class="col-md-12"> 
    <div id="calendar"> 
     <?php 
      $dateComponents = getdate(); 
      $month = $dateComponents['mon']; 
      $year = $dateComponents['year']; 
      echo build_calendar($month,$year); 
     ?> 
    </div> 
   </div> 
  </div> 
 </div> 
</body>
</html>

Source