Complete Code For Checking Armstrong number.
<!DOCTYPE html> <html> <head> <title>How To Implement PHP Code For Checking Armstrong number</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"> </head> <style> body { background: black; } </style> <body> <body> <div class="container"> <br/><br/> <div class="text-center"> <h1 id="color" style="color: white;">PHP Code For Checking Armstrong number</h1> </div> <div class="well"> <form action="" method="post" enctype="multipart/form-data"> <label>Enter a Number</label> <input type="text" name="number" value=""><br><br> <input type="submit" value="submit" class="btn btn-success" name="submit"> </form> <?php if (isset($_POST['submit'])) { //get the number entered $number = $_POST['number']; //store entered number in a variable $a = $number; $sum = 0; //run loop till the quotient is 0 while ($a != 0) { $rem = $a % 10; //it will find reminder $sum = $sum + ($rem * $rem * $rem); //cube the reminder and add it to the sum variable till the loop ends $a = $a / 10; //find quotient. if 0 then loop again } //if the entered number and $sum value matches then it is an armstrong number if ($number == $sum) { echo "$number an Armstrong Number"; } else { echo "$number is not an Armstrong Number"; } } ?> </div> </div> </body> </html>