PHP: variable shift to zero

I just stumbled upon something in a PHP manual that is new to me ...

Bringing a variable to null will delete the variable and change it. ( Source )

Now I wonder how this can be done ... I tried (null) and (NULL), but it seems to be interpreted as a null value, not a null type. I know this question should sound funny, but does anyone know how to distinguish it from zero?

+3
source share
4 answers

use (unset) instead of (null).

+4
source
$a = (unset) $a;

See casting type .

+6
source

Type casting Type Juggling ...

$varName = (unset)$varName;
+2

, isset false.

$test = "a";
$test = null;
var_dump( isset( $test ));

Moving variables in PHP are accomplished by assigning its specific value (for example, $ foo = intval ($ bar), etc.). If you put NULL in a variable, it will be interpreted as NULL (type NULL), isset will return false if the variable is type NULL

Edit: if you want to completely disable the variable, use

unset ($ test);
+1
source

Source: https://habr.com/ru/post/1786409/


All Articles