PHP SplObjectStorage current() Function Last Updated : 23 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The SplObjectStorage::current() function is an inbuilt function in PHP which is used get the current entry of storage. Syntax: object SplObjectStorage::current() Parameters: This function does not accept any parameter. Return Value: This function returns the object of the current storage. Below programs illustrate the SplObjectStorage::current() function in PHP: Program 1: php <?php // Declare an SplObjectStorage $storage = new SplObjectStorage(); // Declare new object $obj = new StdClass; // Use attach() function to add object $storage->attach($obj, "GeeksforGeeks"); $storage->rewind(); // Use current() function to get // the current object $object = $storage->current(); $data = $storage->getInfo(); var_dump($object); var_dump($data); ?> Output: object(stdClass)#2 (0) { } string(13) "GeeksforGeeks" Program 2: php <?php // Declare an SplObjectStorage $str = new SplObjectStorage(); // Declare new object $obj1 = new StdClass; $obj2 = new StdClass; $obj3 = new StdClass; $obj4 = new StdClass; // Use attach() function to add object $str->attach($obj1, "GeeksforGeeks"); $str->attach($obj2, "GFG"); $str->attach($obj3, "Geeks"); $str->attach($obj4, "PHP"); $str->rewind(); while($str->valid()) { $index = $str->key(); // Use current() function to get // the current object $object = current($str); $data = $str->getInfo(); var_dump($object); var_dump($data); $str->next(); } ?> Output: bool(false) string(13) "GeeksforGeeks" bool(false) string(3) "GFG" bool(false) string(5) "Geeks" bool(false) string(3) "PHP" Reference: https://www.php.net/manual/en/splobjectstorage.current.php Comment More infoAdvertise with us Next Article PHP SplObjectStorage attach() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplObjectStorage count() Function The SplObjectStorage::count() function is an inbuilt function in PHP which is used to count the number of objects in storage. Syntax: int SplObjectStorage::count() Parameters: This function does not contains any parameter. Return Value: This function returns number of objects in storage. Below progr 1 min read PHP SplObjectStorage detach() Function The SplObjectStorage::detach() function is an inbuilt function in PHP which is used to remove objects from the storage. Syntax: void SplObjectStorage::detach($obj) Parameters: This function accepts a single parameter $obj which specifies the object to be remove from the storage. Return Value: This f 1 min read PHP SplObjectStorage contains() Function The SplObjectStorage::contains() function is an inbuilt function in PHP which is used to check the storage object contains a specified object or not. Syntax: bool SplObjectStorage::contains( $value ) Parameters: This function accepts a single parameter $value which specifies the storage object which 1 min read PHP SplObjectStorage attach() Function The SplObjectStorage::attach() function is an inbuilt function in PHP which is used to add objects into the SplObjectStorage. Syntax: void SplObjectStorage::attach($obj, $val) Parameters: This function accepts two parameters as mention above and described below. $obj: This is required parameter whic 1 min read PHP | SplFileObject current( ) Function The SplFileObject::current() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get current line of file. Syntax: string SplFileObject::current( void ) Parameters: This function does not accept any parameter. Return values: Returns current line of the file. Below P 2 min read PHP | SplFileObject current( ) Function The SplFileObject::current() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get current line of file. Syntax: string SplFileObject::current( void ) Parameters: This function does not accept any parameter. Return values: Returns current line of the file. Below P 2 min read Like