array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'ds-stack.peek.php', 1 => 'Ds\\Stack::peek', 2 => 'Returns the value at the top of the stack', ), 'up' => array ( 0 => 'class.ds-stack.php', 1 => 'Ds\\Stack', ), 'prev' => array ( 0 => 'ds-stack.jsonserialize.php', 1 => 'Ds\\Stack::jsonSerialize', ), 'next' => array ( 0 => 'ds-stack.pop.php', 1 => 'Ds\\Stack::pop', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ds/ds/stack/peek.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

Ds\Stack::peek

(PECL ds >= 1.0.0)

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

Опис

public Ds\Stack::peek(): mixed

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

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

The value at the top of the stack.

Помилки/виключення

UnderflowException if empty.

Приклади

Приклад #1 Ds\Stack::peek() example

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

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

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

Поданий вище приклад виведе щось схоже на:

string(1) "c"