D133 9. Palindrome Number
Title Link
9. Palindrome Number
Topic analysis
This question is very simple. It is to judge whether a given number is a palindrome number. The palindrome number is the same as reading from left to right.
But this question is slightly different from question 7, and the symbols should be the same.
Problem solving ideas
The symbols should also be consistent, which is simple. Directly flip it with the strrev function, and then judge whether it is equal to the original content.
Final code
<?php
class Solution {
/**
* @param Integer $x
* @return Boolean
*/
function isPalindrome($x) {
return $x == strrev($x);
}
}
If you think this article is useful to you, you are welcome to use love power generation.