EmptyIterator::current()
函式返回當前迭代器的當前元素。
用法:
$value = $iterator->current();
引數: 該函式沒有引數。
返回值: 返回當前迭代器的當前元素。
示例:
// 建立一個空的迭代器
$iterator = new EmptyIterator();
// 使用 current() 函式獲取當前元素
$value = $iterator->current();
// 輸出結果
echo $value;
在上面的示例中,由於空迭代器不包含任何元素,因此 current()
返回 null
。