略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: InfiniteIterator::__construct (官方文档)

2021-04-13

InfiniteIterator::__construct

(PHP 5 >= 5.1.0, PHP 7)

InfiniteIterator::__constructConstructs an InfiniteIterator

说明

public InfiniteIterator::__construct ( Iterator $iterator )

Constructs an InfiniteIterator from an Iterator.

参数

iterator

The iterator to infinitely iterate over.

返回值

没有返回值。

错误/异常

Throws an E_RECOVERABLE_ERROR if the iterator parameter is not an Iterator.

范例

Example #1 InfiniteIterator::__construct() example

<?php
$arrayit  
= new ArrayIterator(array('cat','dog'));
$infinite = new InfiniteIterator($arrayit);
$limit    = new LimitIterator($infinite07);
foreach(
$limit as $value)
{
    echo 
"$value\n";
}
?>

以上例程会输出:

cat
dog
cat
dog
cat
dog
cat

参见

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/infiniteiterator.construct.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3