PHP program to check whether the given number is palindrome or not

This PHP program is very useful for IT freshers.

Most of the IT companies ask this program in technical interview.




PHP program to check whether the given number is palindrome or not.

<?php
// PHP program to check whether the given number is palindrome or not
$n=123;
$rev=0;
$n1=$n;
while((int)$n > 0){
$rem = $n % 10;
$rev = ($rev*10) + $rem;
$n = (int)$n / 10;
}
echo "Reverse of $n1 = ".$rev."<br/>";
if($n1 == $rev){
echo "$n1 is palindrom number";
}else{
echo "$n1 is not palindrom number";
}
?>

This blog is very useful for IT Freshers.
Use right side menus to read useful posts like Resume Tips, Interview questions, Jobs, Programming, etc.

Other important Posts:
How to find PHP version through command prompt in windows? 

Important PHP string functions


No comments:

Post a Comment

We are here to listen you, Comment your valueable opinion...!!!