PHP SplObjectStorage setInfo() Function Last Updated : 23 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The SplObjectStorage::setInfo() function is an inbuilt function in PHP which is used to set the data associated with the current iterator entry. Syntax: void SplObjectStorage::setInfo( $val ) Parameters: This function accepts a single parameter $val which specifies the data to be associate to the current iterator entry of the storage. Return Value: This function does not return any value. Below programs illustrate the SplObjectStorage::setInfo() function in PHP: Program 1: php <?php $str = new SplObjectStorage(); $obj1 = new StdClass; $str->attach($obj1, "GeeksforGeeks"); $str->rewind(); // Set new info for $obj1 in storage $str $str->setInfo("new_GeeksforGeeks"); // Print Result var_dump($str[$obj1]); ?> Output: string(17) "new_GeeksforGeeks" Program 2: php <?php $obj1 = new StdClass; $obj2 = new StdClass; $obj3 = new StdClass; $gfg = new SplObjectStorage(); $gfg[$obj1] = "GFG"; $gfg[$obj2] = "GeeksClasses"; $gfg[$obj3] = "SUDO"; // Using rewind function $gfg->rewind(); while($gfg->valid()) { $gfg->setInfo("Modified_GFG_DATA"); var_dump($gfg->getInfo()); // Moving to next element $gfg->next(); } ?> Output: string(17) "Modified_GFG_DATA" string(17) "Modified_GFG_DATA" string(17) "Modified_GFG_DATA" Reference: https://www.php.net/manual/en/splobjectstorage.setinfo.php Comment More infoAdvertise with us Next Article PHP SplObjectStorage removeAll() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplObjectStorage rewind() Function The SplObjectStorage::rewind() function is an inbuilt function in PHP which is used to rewind the iterator to the first storage element. Syntax: void SplObjectStorage::rewind() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below progr 1 min read PHP SplObjectStorage serialize() Function The SplObjectStorage::serialize() function is an inbuilt function in PHP which is used to serialize the result of the storage. Syntax: string SplObjectStorage::serialize() Parameters: This function does not accept any parameter. Return Value: This function returns a string which is the representatio 1 min read PHP SplObjectStorage getinfo() Function The SplObjectStorage::getinfo() function is an inbuilt function in PHP that is used to get the data associated with the object by the current iterator position. Syntax: mixed SplObjectStorage::getinfo() Parameters: This function does not accept any parameter. Return Value: This function returns the 1 min read PHP SplObjectStorage removeAll() Function The SplObjectStorage::removeAll() function is an inbuilt function in PHP which is used to remove all objects contained in another storage from the current storage. Syntax: void SplObjectStorage::removeAll( $obj ) Parameters: This function accepts a single parameter $obj which specify the storage to 1 min read PHP SplObjectStorage key() Function The SplObjectStorage::key() function is an inbuilt function in PHP which is used to get the index of the currently pointing iterator. Syntax: int SplObjectStorage::key() Parameters: This function does not accept any parameter. Return Value: This function returns the index at which the iterator curre 1 min read PHP SplObjectStorage next() Function The SplObjectStorage::next() function is an inbuilt function in PHP which is used to move to next entry of storage. Syntax: void SplObjectStorage::next() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs illustrate the SplO 1 min read Like