What is Ds\Queue::isEmpty() in PHP?

The Queue::isEmpty() function in PHP is used to check if a queue is empty. Queue::isEmpty() returns true (1) if the queue is empty. Otherwise, it returns false.

The illustration below shows the visual representation of the Queue::isEmpty() function.

Visual representation of Queue::isEmpty() function

Syntax

queue_name->isEmpty()
## where the queue_name is the name of the queue

Parameter

The Queue::isEmpty() function does not require any parameters.

Return value

The Queue::isEmpty() function returns true (1) if the queue is empty. Otherwise, it returns false.

Code

<?php
$queue1 = new \Ds\Queue();
#sending the list of elements
$queue->push(1,3,5,2,0);
echo("Queue1 is empty");
echo($queue1->isEmpty());
######output######
#Queue1 is empty :
$queue2 = new \Ds\Queue();
echo("Queue2 is empty");
echo($queue2->isEmpty());
######output######
#Queue2 is empty: 1
?>
New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources