PHP - Fonction Ds \ Stack :: peek ()

La fonction Ds \ Stack :: peek () peut renvoyer la valeur en haut d'une pile.

Syntaxe

public mixed Ds\Stack::peek( void )

La fonction Ds \ Stack :: peek () peut retourner la valeur en haut d'une pile mais ne la supprime pas.

La fonction Ds \ Stack :: peek () n'a aucun paramètre.

La fonction Ds \ Stack :: peek () peut lancer UnderflowException si elle est vide.

Exemple

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