Traversable (interface)

The Traversable interface

Introduction

(PHP 5 >= 5.0.0, PHP 7)

Interface to detect if a class is traversable using foreach.

Abstract base interface that cannot be implemented alone. Instead it must be implemented by either IteratorAggregate or Iterator.

Note:

Internal (built-in) classes that implement this interface can be used in a foreach construct and do not need to implement 登录查看完整内容