PHP: Assign null if not set
Is there a sort of assign-if-not-empty-otherwise-assign-null function in PHP? I'm looking for a cleaner alternative to the following: $variable = (!empty($item)) ? $item : NULL; It would also be handy if I could specify the default value; for instance, sometimes I'd like ' ' instead of NULL. I could write my own function, but is there a native solution? It should be noted that I'm trying to avoid a notice for undefined values.
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.