note 114441 deleted from control-structures.if by peehaa
| From: | peehaa@php.net | Date: | Wed, 12 Oct 2016 13:08:27 +0000 |
| Subject: | note 114441 deleted from control-structures.if by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206848@lists.php.net to get a copy of this message | ||
Note Submitter: Aldee Mativo
----
If you intend only a single line (one-way) conditional script, you can do the following:
empty($user) || $user->save();
if $user variable is empty, it will not execute $user->save(). Otherwise it will perform saving
operation. In other words/form of expression, it can be expressed like this:
if(!empty($user))
$user->save();