Page 1 of 1

Simplier way to overwrite a variable?

Posted: Tue Feb 02, 2010 12:30 am
by Daz
Is there a better way to do the following:

Code: Select all

$var = ( is_null($var) ) ? $newValue : $var;

Re: Simplier way to overwrite a variable?

Posted: Tue Feb 02, 2010 12:29 pm
by AbraCadaver
Dunno. What are you trying to do? If you're trying to check a var for null and if it is not null, assign it another value, and if it is null, then assign it the value of itself (which is null), then that looks fine.