How can CSS classes be used to style even and odd rows in a PHP-generated table?

To style even and odd rows in a PHP-generated table using CSS classes, you can use a conditional statement within the loop that generates the table rows. Inside the loop, you can check if the current row number is even or odd, and then assign a corresponding CSS class to the table row element. In the CSS, you can define styles for the even and odd classes to differentiate the styling of the rows.

<table>
<?php
for ($i = 0; $i < 10; $i++) {
    $row_class = ($i % 2 == 0) ? 'even' : 'odd';
    echo "<tr class='$row_class'><td>Row $i</td></tr>";
}
?>
</table>
```

```css
.even {
    background-color: lightgray;
}

.odd {
    background-color: white;
}