Take consideration when utilizing this method and using the returned value of isset([value]). The value of isset([value]) will be false for null values.
I ran into this problem when checking isset([value]) against array elements whose value was null.
Example:
<?php
$array = array(null, 1, 2, 3);
$isSet = isset($array[0]);
var_dump($isSet); // output: boolean(false)
class AClass {
public $array = (null, 1, 2, 3);
function valid() {
return isset($this->array[0]);
}
}
$class = new AClass;
var_dump($class->valid()); // output: boolean(false)
?>
Iterator::valid
(PHP 5 >= 5.0.0)
Iterator::valid — Checks if current position is valid
Descrierea
abstract public boolean Iterator::valid
( void
)
This method is called after Iterator::rewind() and Iterator::next() to check if the current position is valid.
Parametri
Această funcție nu are parametri.
Valorile întoarse
The return value will be casted to boolean and then evaluated.
Întoarce valoarea TRUE în cazul
succesului sau FALSE în cazul eșecului.
hyponiq at gmail dot com
26-Sep-2011 04:12
seva dot lapsha at gmail dot com
01-Aug-2009 06:19
If Iterator::valid() returns false, the foreach() loop will be terminated.
