Warning: Illegal type returned from MultipleIterator::key() in D:\www\mytest\test.php
按照老师的代发,我的运行出来是有这个warning,php版本5.3.28。这是怎么回事呢?
Warning: Illegal type returned from MultipleIterator::key() in D:\www\mytest\test.php
按照老师的代发,我的运行出来是有这个warning,php版本5.3.28。这是怎么回事呢?
2014-08-18
1 2 3 4 5 6 7 8 9 10 11 | 最初的代码如下: $idIter = new ArrayIterator( array ( '01' , '02' )); $nameIter = new ArrayIterator( array ( '张三' , '李四' )); $mit = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); $mit ->attachIterator( $idIter , 'id' ); $mit ->attachIterator( $nameIter , 'name' ); foreach ( $mit as $key => $val ) { print_r( $val ); } |
以上代码会报warning错误
但是,但我把$key删除过后,就没问题了~
$idIter=new ArrayIterator(array('01','02'));
$nameIter=new ArrayIterator(array('张三','李四'));
$mit=new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
$mit->attachIterator($idIter,'id');
$mit->attachIterator($nameIter,'name');
foreach($mit as $val)
{
print_r($val);
}
举报