PHP mysqli_result: Use Traversable interface with fetch_object

后端 未结 3 1249
青春惊慌失措
青春惊慌失措 2021-01-13 16:11

the PHP mysqli_result class implements the Traversable interface for some time now. This gives some interesting possibilities like the following piece of code:



        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 16:32

    Note:

    This is an internal engine interface which cannot be implemented in PHP scripts. Either IteratorAggregate or Iterator must be used instead. When implementing an interface which extends Traversable, make sure to list IteratorAggregate or Iterator before its name in the implements clause.

    i.e. you'll find the interface definition at http://docs.php.net/class.iterator and/or http://docs.php.net/class.iteratoraggregate

提交回复
热议问题