The Stack::isEmpty()
function in PHP is used to check if a stack is empty. Stack::isEmpty()
returns true
if the stack is empty. Otherwise, it returns false
.
The illustration below shows a visual representation of the Stack::isEmpty()
function.
stack_name->isEmpty()
## where the stack_name is the name of the stack
The Stack::isEmpty()
function does not require any parameters.
The Stack::isEmpty()
function returns true
(1
) if the queue is empty. Otherwise, it returns false
.
<?php$stack1 = new \Ds\Stack();#sending the list of elements$stack1->push(1,3,5,2,0);echo("Stack1 is empty: ");echo($stack1->isEmpty());$stack2 = new \Ds\Stack();echo("\nStack2 is empty: ");echo($stack2->isEmpty());?>
Stack1 is empty:
Stack2 is empty: 1