How can one display weekends in red font when programming a calendar in PHP?

To display weekends in red font when programming a calendar in PHP, you can use PHP's date functions to determine if the current day is a weekend (Saturday or Sunday) and then apply a CSS style to change the font color to red for those days.

<?php
for ($day = 1; $day <= 31; $day++) {
    $date = date("Y-m-$day");
    $dayOfWeek = date('N', strtotime($date));

    if ($dayOfWeek == 6 || $dayOfWeek == 7) {
        echo "<span style='color: red;'>$day</span> ";
    } else {
        echo "$day ";
    }
}
?>