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.
Result of php executing
Full code of perf.php
- <html>
- <head><title>Perfect num</title>
- </head>
- <body>
- <form action="" method="POST">
- Enter a Number
- <input type=text name=num>
- <input type=submit>
- </form>
- </body>
- </html>
- <?php
- if($_POST)
- {
- $sum=0;
- $n=$_POST['num'];
- for($i=1;$i<$n;$i++)
- {
- if($n%$i==0)
- $sum=$sum+$i;
- }
- if($sum==$n)
- echo $n." is perfect";
- else if($sum>$n)
- echo $n." is abundant";
- else
- echo $n." is deficient";
- }
- ?>