fork download
  1. <?php
  2. function isPalindrome($str) {
  3. return $str === strrev($str);
  4. }
  5.  
  6. // Test the function
  7. $string = "radar";
  8. if (isPalindrome($string)) {
  9. echo "$string is a palindrome.";
  10. } else {
  11. echo "$string is not a palindrome.";
  12. }
  13. ?>
  14.  
Success #stdin #stdout 0.03s 25816KB
stdin
Standard input is empty
stdout
radar is a palindrome.