PHP 8.4.0 RC4 available for testing

Ds\Stack::peek

(PECL ds >= 1.0.0)

Ds\Stack::peekReturns the value at the top of the stack

Descrizione

public Ds\Stack::peek(): mixed

Returns the value at the top of the stack, but does not remove it.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

The value at the top of the stack.

Errori/Eccezioni

UnderflowException if empty.

Esempi

Example #1 Ds\Stack::peek() example

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

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

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

Il precedente esempio visualizzerà qualcosa simile a:

string(1) "c"
add a note

User Contributed Notes

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