perf - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of perf.php

  1. <html>
  2. <head><title>Perfect num</title>
  3. </head>
  4. <body>
  5. <form action="" method="POST">
  6. Enter a Number
  7. <input type=text name=num>
  8. <input type=submit>
  9. </form>
  10. </body>
  11. </html>
  12.  
  13. <?php
  14. if($_POST)
  15. {
  16. $sum=0;
  17. $n=$_POST['num'];
  18. for($i=1;$i<$n;$i++)
  19. {
  20. if($n%$i==0)
  21. $sum=$sum+$i;
  22. }
  23. if($sum==$n)
  24. echo $n." is perfect";
  25. else if($sum>$n)
  26. echo $n." is abundant";
  27. else
  28. echo $n." is deficient";
  29. }
  30. ?>
File Description
  • perf
  • PHP Code
  • 24 Apr-2023
  • 410 Bytes
You can Share it: