• PHP Video Tutorials

PHP - Ds\Queue::peek() Function



Ds\Queue::peek() function can return a value at the front of a queue.

Syntax

public mixed Ds\Queue::peek( void )

Ds\Queue::peek() function can return a value at the front of a queue but do not remove it.

Ds\Queue::peek() function doesn't have any parameters.

Ds\Queue::peek() function can throw UnderflowException if empty.

Example

<?php  
   $queue = new \Ds\Queue();  
   $queue->push("Tutorials"); 
   $queue->push("Point"); 
   $queue->push("India"); 
  
   echo "The queue is: \n"; 
   print_r($queue); 
  
   echo "\n The element at front is:"; 
   print_r($queue->peek()); 
?>
php_function_reference.htm
Advertisements