Nota: isset() č un costrutto del linguaggio.
Restituisce TRUE se la variabile esiste; FALSE in caso contrario.
Se una variabile č stata cancellata con unset(), non potrā essere isset(). La funzione isset() restituirā FALSE se viene utilizzata per testare una variabile valorizzata a NULL. Inoltre occorre notare che il byte NULL ("\0") non equivale alla costante PHP NULL.
<?php $a = "test"; $b = "anothertest"; echo isset ($a); // TRUE echo isset ($a, $b) //TRUE unset ($a); echo isset ($a); // FALSE echo isset ($a, $b); //FALSE $foo = NULL; print isset ($foo); // FALSE ?> |
Questo esempio utilizza gli elementi di un array:
<?php $a = array ('test' => 1, 'hello' => null); echo isset ($a['test']); // TRUE echo isset ($a['foo']); // FALSE echo isset ($a['hello']); // FALSE echo array_key_exists('hello', $a); // TRUE ?> |
Vedere anche empty(), unset() e array_key_exists().