<?php
$sum = 0;
for ($i = 2; $i <= 10; $i += 2) {
$sum += $i;
}
echo "The sum of even numbers between 1 and 10 is: $sum";
?>
<?php
$sum = 0;
for ($i = 2; $i <= 10; $i += 2) {
$sum += $i;
}
echo "The sum of even numbers between 1 and 10 is: $sum";
?>
Related
Write a PHP script that sets a cookie with user preferences and retrieves it on subsequent visits. |
How to get the largest element in an array of numbers |
How to check if a given number is a perfect number. |
Write a PHP script that generates and displays a list of the first 10 Fibonacci numbers. |
Create a simple PHP script that calculates the sum of all even numbers between 1 and 10. |
Write a PHP script that parses JSON data and displays specific information. |
Write a PHP script that generates a random password of a specified length. |
Write a PHP script that generates and displays a simple multiplication table for the numbers 1 to 5. |
