downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Iterator> <Öntanımlı Arayüzler
[edit] Last updated: Fri, 17 May 2013

view this page in

Traversable arayüzü

(Bir sürüm bilgisi bulunamadı; sadece SVN'de olabilir.)

Giriş

Bir sınıf foreach kullanarak çaprazlanabiliyorsa bunu saptayan arayüz.

Tek başına gerçeklenemeyen bir soyut temel arayüz olup ya IteratorAggregate ya da Iterator olarak gerçeklenmelidir.

Bilginize:

Bu arayüzü gerçekleyen yerleşik sınıflar bir foreach oluşumunda kullanılabilir ve IteratorAggregate ya da Iterator olarak gerçeklenmeleri gerekmez.

Bilginize:

Bu dahili bir motor arayüz olup PHP betiklerinde gerçeklenemez. Yerine IteratorAggregate veya Iterator kullanılmalıdır.

Arayüz Sözdizimi

Traversable {
}

Bu arayüzün yöntemleri yoktur. Tek amacı çaprazlanabilir tüm sınıflar için temel arayüz olmaktır.



add a note add a note User Contributed Notes Traversable - [1 notes]
up
11
kevinpeno at gmail dot com
2 years ago
While you cannot implement this interface, you can use it in your checks to determine if something is usable in for each. Here is what I use if I'm expecting something that must be iterable via foreach.

<?php
   
if( !is_array( $items ) && !$items instanceof Traversable )
       
//Throw exception here
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites