Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.php > #3995

Re: "bessere" schreibweise

Path csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups de.comp.lang.php
Subject Re: "bessere" schreibweise
Date Thu, 29 Dec 2016 18:39:10 +0100
Organization solani.org
Lines 31
Message-ID <o43hmk$an4$1@solani.org> (permalink)
References <o43ep5$fim$1@news.albasani.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace solani.org 1483033108 10980 eJwNyMEBwCAIA8CViCHYjoMg+4/Q3vPEQNT2ULhGcx1PwMfqGiJZpI5AWmf2xpumP7TsSr3OBwtPEHw= (29 Dec 2016 17:38:28 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 29 Dec 2016 17:38:28 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1
Cancel-Lock sha1:lN4olYlkDFuvPsI8+frDVOWYE9U=
X-NNTP-Posting-Host eJwFwYkBgDAIA8CVUBqecSIl+4/gHTyemDyBOBDE61/HuyWqki3aMBa4nbItN7hnTTqMgP0wuBEO
X-User-ID eJwNysERwDAIA7CVCsYGxuGSY/8RGr1FyHQyRAWXOyS8elYZKDM/3nplLnwxtytf41cY62P6Af4LD+0=
In-Reply-To <o43ep5$fim$1@news.albasani.net>
Xref csiph.com de.comp.lang.php:3995

Show key headers only | View raw


Am 29.12.2016 um 17:48 schrieb Jan Novak:

> gibt es eine "bessere" oder kürzere schreibweise für folgende Sachlage:
> 
> if ($a and $b) {
>  [do something]
> } else {
>   if (!$a){
>     [do on false $a]
>   } else {
>     [do on false $b]
>   }
> }

Eine *mögliche* Alternative:

if (!$a) {
  // do if $a is "falsey"
} elseif (!$b) {
  // do if $b is "falsey"
} else {
  // do if $a and $b are "truthy"
}

Aber eigentlich finde ich beide Varianten nicht "schön".  Je nachdem was
in den then- und else-Zweigen gemacht wird, kann das vermutlich
verbessert werden.

-- 
Christoph M. Becker

Back to de.comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

"bessere" schreibweise Jan Novak <repcom@gmail.com> - 2016-12-29 17:48 +0100
  Re: "bessere" schreibweise "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-12-29 18:39 +0100
    Re: "bessere" schreibweise Sebastian Suchanek <sebastian.suchanek@gmx.de> - 2016-12-29 21:51 +0100
      Re: "bessere" schreibweise Niels Braczek <nbraczek@freenet.de> - 2016-12-30 00:26 +0100

csiph-web