First let me tell you guys, this is my first post and I'm new to Php coding.
I have written the palindrome program in various programming languages with the same logic. They work perfectly on all but in php it's not working. The code is given below, please tell me where am I making the mistake.
Code: Select all
<html>
<head>
<title>Palindrome Checker</title>
</head>
<body>
<?php
$a=$_GET['num'];
$b=$a;
$x=0;
while($a > 0)
{
$x=$x*10;
$x=$x + ($a % 10);
$a=$a / 10;
}
if($x==$b)
{
echo ("Given number is a palindrome!");
}
else
{
echo ("Given number is not a palindrome!");
}
?>
</body>
</html>
Thanks in advance.
Cheers,
Utsav Gupta