Created
May 12, 2019 06:37
-
-
Save fatadz/641c427ba2f13d3074cbace208752c52 to your computer and use it in GitHub Desktop.
Check Palindrome Word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Palindrome | |
{ | |
public static function isPalindrome($word) | |
{ | |
if($word && is_string($word)){ | |
$word = strtolower($word); | |
$wordReverse = strrev($word); | |
$isPalindrome = $word==$wordReverse ? true : false; | |
}else{ | |
$isPalindrome = false; | |
} | |
return $isPalindrome; | |
} | |
} | |
echo Palindrome::isPalindrome('Deleveled'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment