首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

SimpleXMLIterator::current

(PHP 5 >= 5.1.0, PHP 7)

SimpleXMLIterator :: current - 返回当前元素

描述

代码语言:javascript
复制
public mixed SimpleXMLIterator::current ( void )

此方法将当前元素作为SimpleXMLIterator对象返回NULL

参数

该功能没有参数。

返回值

将当前元素作为SimpleXMLIterator对象返回或失败时返回NULL

例子

示例#1 返回当前元素

代码语言:javascript
复制
<?php
$xmlIterator?=?new?SimpleXMLIterator('<books><book>PHP?basics</book><book>XML?basics</book></books>');
var_dump($xmlIterator->current());

$xmlIterator->rewind();?//?rewind?to?first?element
var_dump($xmlIterator->current());
?>

上面的例子将输出:

代码语言:javascript
复制
NULL
object(SimpleXMLIterator)#2 (1) {
  [0]=>
  string(10) "PHP basics"
}

扩展内容

  • SimpleXMLIterator :: key() - 返回当前键
  • SimpleXMLIterator :: rewind() - 倒回到第一个元素
  • SimpleXMLIterator :: valid() - 检查当前元素是否有效
  • SimpleXMLElement

← SimpleXMLIterator

SimpleXMLIterator::getChildren →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com