PHP | Ds\Stack isEmpty() Function

The Ds\Stack::isEmpty() function of PHP Ds\Stack class is used to check whether a Stack is empty or not. This method returns a boolean value, True if the Stack is empty otherwise it returns False.
Syntax:
bool public Ds\Stack::isEmpty ( void )
Parameter: This function does not accept any parameters.
Return Value: This function returns a boolean value True if the stack is Empty otherwise it returns False.
Below programs illustrate the Ds\Stack::isEmpty() function:
Program 1:
PHP
<?php// PHP program to illustrate the // Ds\stack::isEmpty() function // Create a Stack instance$stack = new \Ds\Stack();// Check if stack is Emptyvar_dump($stack->isEmpty());// Pushing elements to Stack$stack->push("Welcome");$stack->push("to");$stack->push("GfG");// Check if stack is Empty againvar_dump($stack->isEmpty());?> |
Output:
bool(true) bool(false)
Program 2:
PHP
<?php// PHP program to illustrate the // Ds\stack::isEmpty() function // Create a Stack instance$stack = new \Ds\Stack();// Check if stack is Emptyvar_dump($stack->isEmpty());// Pushing Mixed value elements to Stack$stack->push("Welcome");$stack->push("to");$stack->push("GfG");$stack->push(10);$stack->push(5.5);// Check if stack is Empty againvar_dump($stack->isEmpty());?> |
Output:
bool(true) bool(false)



