Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: Iterator::valid - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Iterator::valid

2025-04-26

Iterator::valid

(PHP 5, PHP 7, PHP 8)

Iterator::valid检查当前位置是否有效

说明

public Iterator::valid(): bool

此方法在 Iterator::rewind()Iterator::next() 方法之后被调用以此用来检查当前位置是否有效。

参数

此函数没有参数。

返回值

返回将被转换为bool 。成功时返回 true, 或者在失败时返回 false

添加备注

用户贡献的备注 2 notes

up
9
seva dot lapsha at gmail dot com
15 years ago
If Iterator::valid() returns false, the foreach() loop will be terminated.
up
7
Voitcus at gmail dot com
11 years ago
If your class implements also ArrayAccess interface, you could use as valid() body

function valid(){
return $this->offsetExists($this->position);
}

官方地址:https://www.php.net/manual/en/iterator.valid.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3