Home > Backend Development > PHP Tutorial > 2Traversable interface

2Traversable interface

WBOY
Release: 2016-07-29 08:58:06
Original
1512 people have browsed it

2Traversable interface

2Traversable interface


<code><span><span><?php </span><span>$obj</span> = <span>new</span> stdclass();
<span>$obj</span>->prop = <span>'hello'</span>;
var_dump(<span>$obj</span><span>instanceof</span> Traversable); <span>// false</span></span></span></code>
Copy after login
<code>作用:检测一个类是否可以使用 <span>foreach</span> 进行遍历的接口。

php代码中不能用。只有内部的PHP类(用C写的类)才可以直接实现Traversable接口

php代码中使用Iterator或IteratorAggregate接口来实现遍历。

这个接口没有任何方法,它的作用仅仅是作为所有可遍历类的基本接口</code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the 2Traversable (traversal) interface, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template