The Ds\PriorityQueue::peek() Function in PHP is used to get the value present at the front of a PriorityQueue.
mixed public Ds\PriorityQueue::peek ( void )
Parameters: This function does not accepts any parameters.
Return Value: This function returns the value present at the front of this PriorityQueue. The return type of the function is mixed and depends on the type of value stored in the PriorityQueue.
Exception: This function throws an UnderflowException if the PriorityQueue is empty.
Below programs illustrate the Ds\PriorityQueue::peek():
PriorityQueue is: Ds\PriorityQueue Object (  => Three  => Two  => One ) Element at front is: Three
PHP Fatal error: Uncaught UnderflowException
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.