fork download
  1. <?php
  2. $n=0;
  3. $i=0;
  4. $s=0;
  5.  
  6. echo("Please enter value for N\n");
  7. $n=(int)readline();
  8. $s=0;
  9. for($i=1;$i <=n; $i+=1)
  10. {
  11. if($i % 2 == 0)
  12. {
  13. $s=$s+$i;
  14. echo("Current value i=" . $i . " S=". $s);
  15. echo("\n");
  16. }
  17. }
  18. echo("Final result suma is S=". $s);
  19.  
  20. ?>
Success #stdin #stdout #stderr 0.03s 25548KB
stdin
10
stdout
Please enter value for N
Final result suma is S=0
stderr
PHP Warning:  Use of undefined constant n - assumed 'n' (this will throw an Error in a future version of PHP) in /home/mwkxp2/prog.php on line 9