Create a simple PHP script that calculates the sum of all even numbers between 1 and 10.

<?php
$sum = 0;

for ($i = 2; $i <= 10; $i += 2) {
    $sum += $i;
}

echo "The sum of even numbers between 1 and 10 is: $sum";
?>

 

Post your Answer