Click here to Skip to main content
15,916,189 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?php
$sum = 0;
$i = 0;;
for($i=0;$i<=100;$i++)
{
    $sum += i;
}
echo "$sum";

?>
Posted

Replace
PHP
$sum += i;

with
PHP
$sum += $i;

and it should get better.
 
Share this answer
 
I guess you're not getting the sum. If you're not getting any other characters you can echo it like this:
PHP
echo $sum;


[Update after the comment]
PHP
for($i=0;$i<=100;$i++)
{
    $sum += $i;
}



-KR
 
Share this answer
 
v2
Comments
Durjoy39 15-Nov-15 2:34am    
i remove the quote but error also remaining....
i find out my solution. there should be "$" sign before i;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900