Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
queue
isempty
communitycreator

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

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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
?>

RELATED TAGS

php
queue
isempty
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring