} // read the string s $s = fgets(STDIN); // create the Palindrome class object p $p = new Palindrome(); $len = strlen($s); $f = true; //push all the characters of string s to stack for ($i = 0; $i < $len; $i++) { $p->pushCharacter($s[$i]); } //enqueue all the characters of string s to queue for ($i = 0; $i < $len; $i++) { $p->enqueueCharacter($s[$i]); } /* pop the top character from stack dequeue the first character from queue compare both the characters*/ for ($i = 0; $i < $len; $i++) { if ($p->popCharacter() != $p->dequeueCharacter()) { $f = false; break; } } //finally print whether string s is palindrome or not. if ($f) { echo "The word, " . $s . ", is a palindrome."; } else { echo "The word, " . $s . ", is not a palindrome."; }