(Available since version 1.0)
Stack::__construct — Constructs a new stack implemented using a singly linked list
This constructs a new empty stack.
This function has no parameters.
No value is returned.
Example #1 Stack::__construct() example
<?php
require 'vendor/autoload.php'; // A PSR-4 or PSR-0 autoloader
use SEIDS\LinkedLists\Singly\Stack;
$s = new Stack();
$s->push(1);
$s->push(2);
$s->push(3);
while (!$s->isEmpty()) {
echo $s->pop()."\n";
}
?>
The above example will output:
3 2 1