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
$stack = new \Ds\Stack();
var_dump( $stack ->isEmpty());
$stack ->push( "Welcome" );
$stack ->push( "to" );
$stack ->push( "GfG" );
var_dump( $stack ->isEmpty());
?>
|
Output:
bool(true)
bool(false)
Program 2:
PHP
<?php
$stack = new \Ds\Stack();
var_dump( $stack ->isEmpty());
$stack ->push( "Welcome" );
$stack ->push( "to" );
$stack ->push( "GfG" );
$stack ->push(10);
$stack ->push(5.5);
var_dump( $stack ->isEmpty());
?>
|
Output:
bool(true)
bool(false)
Reference: http://php.net/manual/en/ds-stack.isempty.php
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
18 Jan, 2021
Like Article
Save Article