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


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

Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups de.comp.lang.php
Subject Re: prüfen ob eine Funktion etwas ausgibt / - Inhalt hat
Date 2017-10-10 20:24 +0200
Organization PointedEars Software (PES)
Message-ID <1996348.iZASKD2KPV@PointedEars.de> (permalink)
References (1 earlier) <485c337c-feeb-2d57-3e7e-0cdf9c5c8c7f@arcor.de> <1922764.irdbgypaU6@PointedEars.de> <oriedd$b5b$1@solani.org> <2895559.aeNJFYEL58@PointedEars.de> <oriu7h$m6v$1@solani.org>

Show all headers | View raw


Christoph M. Becker wrote:

> Okay, gehen wir mal davon aus, dass sich "the value assigned"/"der
> zugewiesene Wert" tatsächlich eindeutig auf den Ausdruck auf der rechten
> Seite des Operators bezieht. Was ist dann mit folgendem?
> 
>   $a = 'a';
>   $b = 'b';
>   $a .= ($b .= 'c');
> 
> Müsste dann nicht $a === 'ac' sein?

Ja, müsste es nicht :)

   ($b .= 'c')
   → ($b = $b . 'c')
   → ($b . c)
   → 'bc'

   $a .= ($b .= 'c')
   → $a .= ('bc')
   → $a = $a . 'bc'
   → $a = 'abc'
   → 'abc'

Wie erwartet:

$ php -r '$a = "a"; $b = "b"; echo $a .= ($b .= "c"); echo "\n\$a = $a\n\$b 
= $b\n";' 2>/dev/null
abc
$a = abc
$b = bc

> Oder verhalten sich kombinierte Zuweisungsoperatoren eben etwas anders,
> wobei ($a .= $b) als ($a = $a . $b) interpretiert wird?

Ja, anscheinend.

> Dann stellt sich mir allerdings die Frage, wieso
> <https://3v4l.org/pO3N9> und <https://3v4l.org/8Wde8> ein so
  ^^^^^^^^^^^^^^^^^^^^^^^^     ^^^^^^^^^^^^^^^^^^^^^^^^
> unterschiedliches Ergebnis haben.

Bitte nicht (nur) so.

-- 
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

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


Thread

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