Ds\Stack::peek

(PECL ds >= 1.0.0)

Ds\Stack::peekRetorna o valor no topo da pilha

Descrição

public Ds\Stack::peek ( ) : mixed

Retorna o valor no topo da pilha, mas não o remove.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

O valor no topo da pilha.

Erros

UnderflowException se vazio.

Exemplos

Exemplo #1 Exemplo Ds\Stack::peek()

<?php
$stack 
= new \Ds\Stack();

$stack->push("a");
$stack->push("b");
$stack->push("c");

var_dump($stack->peek());
?>

O exemplo acima irá imprimir algo similar à:

string(1) "c"
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top