• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Iterator::valid

    (PHP 5, PHP 7)

    检查当前位置是否有效

    说明

    abstractpublicIterator::valid(void): bool

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

    参数

    此函数没有参数。

    返回值

    返回将被转换为布尔型。成功时返回TRUE,或者在失败时返回FALSE

    If Iterator::valid() returns false, the foreach() loop will be terminated.
    If your class implements also ArrayAccess interface, you could use as valid() body
    function valid(){  
      return $this->offsetExists($this->position);
    }

    上篇:Iterator::rewind