note 99195 added to class.traversable

From: Date: Mon, 02 Aug 2010 17:06:38 +0000
Subject: note 99195 added to class.traversable
Groups: php.notes 
Request: Send a blank email to php-notes+get-171337@lists.php.net to get a copy of this message
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 ?> ---- Server IP: 192.41.42.26 Probable Submitter: 174.47.83.122 ---- Manual Page -- http://www.php.net/manual/en/class.traversable.php Edit -- https://master.php.net/note/edit/99195 Del: integrated -- https://master.php.net/note/delete/99195/integrated Del: useless -- https://master.php.net/note/delete/99195/useless Del: bad code -- https://master.php.net/note/delete/99195/bad+code Del: spam -- https://master.php.net/note/delete/99195/spam Del: non-english -- https://master.php.net/note/delete/99195/non-english Del: in docs -- https://master.php.net/note/delete/99195/in+docs Del: other reasons-- https://master.php.net/note/delete/99195 Reject -- https://master.php.net/note/reject/99195 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171337) next »