30. PHP Program to Read ten numbers and Print their Sum.
How does this program work?
- This program is used to read ten numbers and print their sum using PHP.
Here is the code
<html>
<head>
<title>PHP Program To read ten numbers and print their Sum</title>
</head>
<body>
<?php
$start = 1;
$end = 10;
$sum = 0;
echo "Sum of 10 numbers :"."</br>";
for ($i = $start; $i <= $end; $i++)
{
$sum += $i;
if($i != $end)
{
echo $i.'+';
}
else
{
echo $i;
}
}
echo ' = '.$sum;
return 0;
?>
</body>
</html>