Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.php > #4293
| Path | csiph.com!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: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat |
| Date | Tue, 10 Oct 2017 14:28:32 +0200 |
| Organization | solani.org |
| Lines | 44 |
| Message-ID | <oriedd$b5b$1@solani.org> (permalink) |
| References | <oranpq$1fq$1@dont-email.me> <485c337c-feeb-2d57-3e7e-0cdf9c5c8c7f@arcor.de> <1922764.irdbgypaU6@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | solani.org 1507638509 11435 eJwFwQERADEIAzBL46BlyKE/8C/hEziNXwbBwGI7b8rrTAuDKIyZCfRJap3HL6q1Q1m+hx8WfxEM (10 Oct 2017 12:28:29 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Tue, 10 Oct 2017 12:28:29 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
| X-NNTP-Posting-Host | eJwFwYEBwDAEBMCVCP8YJ6T2H6F3MConnKBjsVbjaegKibnyagQUg7fdm95xts9rVqjmN/4DCswQoA== |
| Content-Language | de-DE |
| In-Reply-To | <1922764.irdbgypaU6@PointedEars.de> |
| X-User-ID | eJwNyEkBwDAIBEBLgeWUQwP4l5DOcxRGdl1MTXR1M+Jilr04naQHylshPPZJHscfXWe2GuigBxYnEQs= |
| Cancel-Lock | sha1:2zyCm52TibbTJao+vtGAJomcBis= |
| Xref | csiph.com de.comp.lang.php:4293 |
Show key headers only | View raw
Am 08.10.2017 um 03:19 schrieb Thomas 'PointedEars' Lahn:
> Christoph M. Becker wrote:
>
>> Meinst du etwas in der folgenden Art?
>>
>> if (function_exists('get_keywords') && $keywords = get_keywords()) {
>> echo "tags: $keywords";
>> }
>
> Zwecks besserer Les- und Wartbarkeit empfehle ich
>
> if (function_exists('get_keywords') && ($keywords = get_keywords())) {
> echo "tags: $keywords";
> }
Ja, das ist sinnvoll. Es gibt möglicherweise auch einige Analyser, die
ohne die Klammerung der Zuweisung eine Warnung ausgeben – ist zumindest
bei C nicht unüblich.
> Zu beachten ist auch, dass das Ergebnis einer Zuweisung der Wert der
> *rechten* Seite, _nicht_ der der linken Seite, ist. Das ist nur solange
> egal, wie auf der linken Seite keine Referenz auf eine Eigenschaft mit
> einem Setter steht. (Das gilt übrigens gleichermassen für ECMAScript.)
>
> $ php -r 'class C { public function __set ($property, $value) {
> $this->$property = (int) $value; }} $o = new C(); echo ($o->x = "foo");
> echo "\n". $o->x . "\n";' 2>/dev/null
> foo
> 0
Interessant – war mir nicht bewusst. Da ist dann wohl das PHP
Handbuch[1] fehlerhaft:
| The value of an assignment expression is the value assigned.
Und auch in der Sprachspezifikation[2] müsste wohl nachgebessert werden.
[1] <http://www.php.net/manual/en/language.operators.assignment.php>
[2] <https://github.com/php/php-langspec/blob/master/spec/10-expressions.md>
--
Christoph M. Becker
Back to de.comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar
prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Josh Mehrtens <jom@mail.invalid> - 2017-10-07 16:19 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-07 19:49 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-08 03:19 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Josh Mehrtens <jom@mail.invalid> - 2017-10-10 13:37 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-10 14:28 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-10 15:31 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2017-10-10 13:58 +0000
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-10 16:07 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-10 18:58 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-10 20:24 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-11 01:02 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat k@rl.pflaesterer.de (Karl Pflästerer) - 2017-10-11 16:38 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-12 00:45 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-07 19:49 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Josh Mehrtens <jom@mail.invalid> - 2017-10-07 23:40 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-08 01:13 +0200
Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat Josh Mehrtens <jom@mail.invalid> - 2017-10-10 13:34 +0200
csiph-web