PHP Ds\Queue peek() Function Last Updated : 23 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Queue::peek() Function in PHP is used to get the value present at the front of a Queue. This function simply returns the element present at the front of a Queue instance without actually removing it. Syntax: mixed public Ds\Queue::peek ( void ) Parameters: This function does not accepts any parameters. Return Value: This function returns the value present at the front of this Queue. The return type of the function is mixed and depends on the type of value stored in the Queue. Exception: This function throws an UnderflowException if the Queue is empty. Below programs illustrate the Ds\Queue::peek() Function in PHP Program 1: php <?php // Declare new Queue $q = new \Ds\Queue(); // Add elements to the Queue $q->push("One"); $q->push("Two"); $q->push("Three"); echo "Queue is: \n"; print_r($q); // Get element at the front echo "\nElement at front is: "; print_r($q->peek()); ?> Output: Queue is: Ds\Queue Object ( [0] => One [1] => Two [2] => Three ) Element at front is: One Program 2: php <?php // Declare new Queue $q = new \Ds\Queue (); echo "Queue is: \n"; print_r($q); // Get element at the front echo "\nElement at front is: "; print_r($q->peek()); ?> Output: PHP Fatal error: Uncaught UnderflowException Reference: http://php.net/manual/en/ds-priorityqueue.peek.php Comment More infoAdvertise with us Next Article PHP | DsStack peek() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_queue Similar Reads PHP DsQueue peek() Function The Ds\Queue::peek() Function in PHP is used to get the value present at the front of a Queue. This function simply returns the element present at the front of a Queue instance without actually removing it. Syntax: mixed public Ds\Queue::peek ( void ) Parameters: This function does not accepts any p 2 min read PHP | DsStack peek() Function The Ds\Stack::peek() function of PHP is used to get the element present at the top of the Stack instance. This function just returns the top element of the stack without removing it from the stack. Syntax: mixed public Ds\Stack::peek ( void ) Parameters: This function does not accept any parameters. 1 min read D3.js queue() Function The d3.queue() function is used to create a queue of a specified size. If the size is not given by default it is taken as infinite. Syntax: d3.queue(size); Parameters: This function accepts a single parameter mentioned above and described below: size: It is the optional parameter if it is not given 2 min read PHP SplQueue::dequeue() Function The SplQueue::dequeue() function is an inbuilt function in PHP which is used to dequeues the node from the queue. Syntax: mixed SplQueue::dequeue() Parameters: This function does not accept any parameter. Return Value: This function return the value of the dequeued node. Below programs illustrate th 1 min read PHP | usleep( ) Function The usleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for specific microseconds. It is similar to the sleep() function which delays execution of the current script for a specified number of seconds, unlike the usleep() function which delays th 2 min read PHP SplQueue::__construct() Function The SplQueue::__construct() function is an inbuilt function in PHP which is used to construct a queue which is implemented using a doubly-linked list. Syntax: void SplQueue::__construct(void) Parameters: This function does not accept any parameter. Return Value: This function does not return any val 1 min read PHP Ds\Queue peek() Function min read Like