note 114441 added to control-structures.if
| From: | AldeeMativo | Date: | Fri, 21 Feb 2014 03:52:22 +0000 |
| Subject: | note 114441 added to control-structures.if | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198577@lists.php.net to get a copy of this message | ||
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();
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/control-structures.if.php
Edit -- https://master.php.net/note/edit/114441
Del: integrated -- https://master.php.net/note/delete/114441/integrated
Del: useless -- https://master.php.net/note/delete/114441/useless
Del: bad code -- https://master.php.net/note/delete/114441/bad+code
Del: spam -- https://master.php.net/note/delete/114441/spam
Del: non-english -- https://master.php.net/note/delete/114441/non-english
Del: in docs -- https://master.php.net/note/delete/114441/in+docs
Del: other reasons-- https://master.php.net/note/delete/114441
Reject -- https://master.php.net/note/reject/114441
Search -- https://master.php.net/manage/user-notes.php