PHP: Assign if not empty?
<p>Is there any sort of assign-if-not-empty-otherwise-assign-null function in PHP?</p>

<p>I'm looking for a cleaner alternative to the following:</p>

<pre><code>$variable = (!empty($item)) ? $item : NULL;
</code></pre>

<p>It would also be handy if I could specify the default value; for instance, sometimes I'd like ' ' instead of NULL.</p>

<p>I could write my own function, but is there a native solution?</p>

<p>Thanks!</p>

<p>EDIT: It sould be noted that I'm trying to avoid a notice for undefined values.</p>
