3
05/11/2024 5:25 am
Konu başlatıcı
Write a PHP script to print the numbers from 1 to 20:
- Print the numbers in a list <ul><li>…</li></ul>
- Print odd lines in blue, even lines in red
1 Yanıt
2
05/11/2024 5:26 am
Here's the answer:
<!DOCTYPE html>
<html>
<head>
<title>Hello PHP</title>
</head>
<body>
<ul>
<?php
for ($i = 1; $i <= 20; $i++) {
if ($i % 2 == 1) {
echo "<li><span style='color: blue'>$i</span></li>";
} else {
echo "<li><span style='color: green'>$i</span></li>";
}
}
?>
</ul>
</body>
</html>
