VOOZH about

URL: https://www.geeksforgeeks.org/php/php-simplexmliterator-current-function/

⇱ PHP | SimpleXMLIterator current() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP | SimpleXMLIterator current() Function

Last Updated : 12 Jul, 2025
The SimpleXMLIterator::current() function is an inbuilt function in PHP which is used to return the current element as a SimpleXMLIterator object or NULL. Syntax:
mixed SimpleXMLIterator::current( void )
Parameters: This function does not accepts any parameters. Return Value: This function returns the current element as a SimpleXMLIterator object on success or NULL on failure. Below programs illustrate the SimpleXMLIterator::current() function in PHP: Program 1:
Output:
NULL
object(SimpleXMLIterator)#2 (1) {
 [0]=>
 string(13) "GeeksforGeeks"
}
Program 2:
Output:
object(SimpleXMLIterator)#2 (1) {
 [0]=>
 string(11) "Noida India"
}
Reference: https://www.php.net/manual/en/simplexmlelement.current
Comment