NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - isset

Trieda

Koreň \ Bez triedy

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ázovDátový typPredvolená hodnotaPopis
$varmixed

The variable about which we want to know whether it exists and does not contain the null value.

$...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

      Aktivity