Returns true if the given string is a palindrome, false otherwise.

Check if the value of strrev($string) is equal to the passed $string.

代码实现

function palindrome($string)
{
  return strrev($string) === (string) $string;
}

使用样例

palindrome('racecar'); // true
palindrome(2221222); // true