# Palindrome Number Program in PHP

## Palindrome Number :-

palindromic number or numeral palindrome is a number that remains the same when its digits are reversed. Like 53235,

Below are the example palindrome number:-

`121 , 212 , 12321 , 16461`

## #Steps to Check a Palindrome Number :-

• Take a Number
• Now reverse its digit
• Now compare both the numbers
• if both are equals to each other then return "Number is Palindrome".
• else return "Number is not Palindrome"

Here I am writing the PHP program to check whether a number is palindrome or not.

### Palindrome Number Program Without of Using PHP Predefined Function :-

```<?php
\$number = 53235;
\$p = \$number;
\$revnum =0;
while(\$number != 0){ //echo 'i am';
\$revnum = \$revnum*10 + \$number % 10 ;//echo '-';
\$number = (int)(\$number/10);
//echo '<br/>';
}
if(\$revnum==\$p){
echo \$p.' is palindrome number';
}
else{
echo 'number is not palindrome';
}
?>
```

Output :- 53235 is palindrome number

### Using function that take a number as an input :-

```<?php
function checkPalindrome(\$number){
\$p = \$number;
\$revnum =0;
while(\$number != 0){
\$revnum = \$revnum*10 + \$number % 10 ;
\$number = (int)(\$number/10);
}
if(\$revnum==\$p){
echo \$p.' is palindrome number';
//return TRUE;
}
else{
echo 'number is not palindrome';
//return FALSE;
}
}
echo checkPalindrome('121');
?>```

Output :- 121 is palindrome number

### Using PHP Predefined Function :-

```<?php
\$number = '121';

if(strrev(\$number) == \$number){
echo \$number.' is palindrome number';
}
else{
echo 'number is not palindrome';
}
?>```

Output :- 121 is palindrome number

Using the above program you can check whether a number is palindrome or not in PHP.