The below program checks for a Palindrome number using a loop. The PHP echo statement is used to output the result on the screen. A number is called as a Palindrome number if the number remains same even when its digits are reversed.
Palindrome Number:
abcde = edcba
Example: 24142, 1234321, etc.
Example<!DOCTYPE html>
<html>
<body>
<?php
$num = 123454321;
$x = 0;
$n =$num;
while(floor($num))
{
$mod = $num%10;
$x = $x * 10 + $mod;
$num = $num/10;
}
if($n==$x)
{
echo "$n is a Palindrome number.";
}
else
{
echo "$n is not a Palindrome number.";
}
?>
</body>
</html>
Output:
123454321 is a Palindrome number.