I just stumbled upon a thing in the PHP manual that is new to me...
Casting a variable to null will remove the variable and unset its value. (Source)
Now I wonder how this can be done... I tried (null) and (NULL) but it seems to be interpreted as the value null, not the type null. I know this question must sound ridiculous, but does somebody know how to cast to null?
Update: Since posting this 9 years ago, casting to unset has changed behavior and is deprecated. The last defined behavior was equivalent to setting the variable equal to NULL. You can either set the variable equal to NULL to retain the variable but indicate it has no value, or you can call the unset function to remove it entirely.
Original Answer:
$a = (unset) $a;
See type casting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With