function dequeueCharacter() { $retValue = $this->queueHead->value; $this->queueHead = $this->queueHead->next; return $retValue; } } // 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; } }