I have a stack class that has a pop function like so... /** * Pop the Stack. * @returns mixed The reference to the popped element. */ function &pop() { $element = &$this->top(); array_pop($this->_stack); return $element; } It seems to be returning the reference to the popped element, but how do I access the actual value of the element. Also after construction an object like so, $mystack=new Stack, how do I destruct it so it does not take memory when i no longer need it.