Thursday, June 18, 2026
HomeLanguagesPHP | ArrayObject getFlags() Function

PHP | ArrayObject getFlags() Function

The ArrayObject::getFlags() function is an inbuilt function in PHP which is used to get the behavior of flags of the ArrayObject.

Syntax:

int ArrayObject::getFlags( void )

Parameters: This function does not accept any parameters.

Return Value: This function returns the behavior flags of the ArrayObject.

Below programs illustrate the ArrayObject::getFlags() function in PHP:

Program 1:




<?php 
// PHP program to illustrate the 
// ArrayObject::getFlags() function 
  
// Declare an array and convert it into
// array object
$arrObject = new ArrayObject(
    array('Geeks', 'for', 'Geeks')
); 
  
// Use ArrayObject::getFlags() function
// to get the behavior of flags
$flag = $arrObject->getFlags(); 
  
var_dump($flag); 
  
// Set a new flags
$arrObject->setFlags(ArrayObject::ARRAY_AS_PROPS);
  
// Use ArrayObject::getFlags() function
// to get the behavior of flags
$flag = $arrObject->getFlags(); 
  
var_dump($flag); 
  
?> 


Output:

int(0)
int(2)

Program 2:




<?php 
// PHP program to illustrate the 
// ArrayObject::getFlags() function 
  
// Declare an associative array
$arr = array(
    "a" => "Welcome",
    "b" => "to", 
    "c" => "neveropen"
); 
  
// Create array object 
$arrObject = new ArrayObject($arr); 
  
// Use ArrayObject::getFlags() function
// to get the behavior of flags
$flag = $arrObject->getFlags(); 
  
var_dump($flag); 
  
// Set a new flags
$arrObject->setFlags(ArrayObject::STD_PROP_LIST);
  
// Use ArrayObject::getFlags() function
// to get the behavior of flags
$flag = $arrObject->getFlags(); 
  
var_dump($flag); 
  
?>


Output:

int(0)
int(1)

Reference: https://www.php.net/manual/en/arrayobject.getflags.php

RELATED ARTICLES

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6898 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6965 POSTS0 COMMENTS