PHP - isset
Trieda
Metóda - isset
(PHP 4, PHP 5, PHP 7)
The isset() function is used to determine whether a variable or
an array's key exists and is not null.
If we pass an inaccessible object property to the function, the
__isset() magic method of the given object will be invoked.
We can use the unset() function to unset a variable or an array
index.
Note: isset() is not a function but a language
construct. Therefore, it can't be e.g. stored in a variable.
Procedurálne
- function isset (mixed $var, mixed $...) : bool
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $var | mixed | The variable about which we want to know whether it exists and does not
contain the | |
| $... | mixed | Another variables for checking |
Mávratovej hodnoty
Vracia: bool
The function returns true if all the arguments exist and are not
null. Returns false otherwise.
Príklady
<?php
$array = array(
0 => 'value',
'key' => 'value'
);
$firstName = 'Michael';
var_dump(isset($array[0]));
var_dump(isset($array[1]));
var_dump(isset($firstName));
var_dump(isset($lastName));
var_dump(isset($firstName, $array[0], $array['key']));
var_dump(isset($firstName, $array[0], $array[1]));
Súvisiace manuály
- function array_key_exists (mixed $key, array $array) : bool
- function defined (string $name) : bool
- function empty (mixed $var) : bool
- function is_null (mixed $var) : bool
