Palindrome number Program in PHP


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 Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements