Thursday, January 22, 2026
HomeLanguagesPHP SplPriorityQueue isCorrupted() Function

PHP SplPriorityQueue isCorrupted() Function

The SplPriorityQueue::isCorrupted() function is an inbuilt function in PHP that is used to tells the priority queue is in a corrupted state or not.

Syntax:

bool SplPriorityQueue::isCorrupted()

Parameters: This function does not accept any parameter.

Return Value: This function returns true if the priority queue is corrupted state otherwise it returns false.

 

Example:

PHP




<?php
  
// Declare a class
class priorityQueue extends SplPriorityQueue {
      
    // Compare function to compare priority
    // queue elements
    public function compare($p1, $p2) {
        if ($p1 === $p2) return 0;
        return $p1 < $p2 ? -1 : 1;
    }
}
  
// Create an object of priority queue
$obj = new priorityQueue();
  
// Insert elements into the queue
$obj->insert("Geeks",2);
$obj->insert("GFG",1);
$obj->insert("G4G",3);
$obj->insert('G',4);
  
// Use isCorrupted() function to check
// priority queue is in corrupted state
// or not
var_dump($obj->isCorrupted());
  
?>


Output

bool(false)

Reference: https://www.php.net/manual/en/splpriorityqueue.iscorrupted.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen 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!
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS