• PHP Video Tutorials

PHP - Ds\Stack::peek() Function



Ds\Stack::peek() function can return the value at the top of a stack.

Syntax

public mixed Ds\Stack::peek( void )

Ds\Stack::peek() function can return the value at the top of a stack but do not remove it.

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

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

Example

<?php 
   $stack = new \Ds\Stack(); 
   
   $stack->push("Tutorials"); 
   $stack->push("Point"); 
   $stack->push("India"); 
  
   print_r($stack->peek()); 
?>
php_function_reference.htm
Advertisements