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 accepts 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 program to illustarte the // isEmpty() function // Create a Stack instance $stack = new \Ds\Stack(); // Check if stack is Empty var_dump($stack->isEmpty()); // Pushing elements to Stack $stack->push("Welcome"); $stack->push("to"); $stack->push("GfG"); // Check if stack is Empty again var_dump($stack->isEmpty()); ?> |
Output:
bool(true) bool(false)
Program 2:
<?php // PHP program to illustarte the // isEmpty() function // Create a Stack instance $stack = new \Ds\Stack(); // Check if stack is Empty var_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 again var_dump($stack->isEmpty()); ?> |
Output:
bool(true) bool(false)
Reference: http://php.net/manual/en/ds-stack.isempty.php
Recommended Posts:
- PHP | Ds\Collection isEmpty() Function
- PHP | Ds\Deque isEmpty() Function
- PHP | Ds\Map isEmpty() Function
- PHP | Ds\Vector isEmpty() Function
- PHP Ds\PriorityQueue isEmpty() Function
- PHP Ds\Queue isEmpty() Function
- PHP Ds\Set isEmpty() Function
- PHP | SplDoublyLinkedList isEmpty() Function
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

