Palindrome number Program in PHP

Advertisements

Prev Tutorial Next Tutorial

Palindrome number Program in PHP

Palindrome number means number remain same after reverse any number. For example we reverse 121 result will be 121 so it is palindrome number.

Steps to check number is palindrome or not

  • Take a number.
  • Reverse the input number.
  • Compare both the numbers.

Palindrome number Program in PHP

<?php

$num = 121;
$p=$num;
$revnum = 0;
while ($num != 0)
{
$revnum = $revnum * 10 + $num % 10;
//below cast is essential to round remainder towards zero
$num = (int)($num / 10); 
}
 
if($revnum==$p)
{
echo $p," is Palindrome number";
}
else
{
echo $p." is not Palindrome number";
}

?>

Output

	
121 is Palindrome number

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements