Christian Kruse: Warum geht das nicht?

Beitrag lesen

Hallo Thomas,

(gekuerzt):

if($insert = @mysql_query("$query"))
  { echo 'Der Eintrag wurde erfolgreich geändert!'; }
else
  { echo 'Leider konnte der Eintrag nicht verändert werden.'; }

Die _Zuweisung_
$insert = @mysql_query("$query")
wird vermutlich immer "TRUE" zurueckgeben,
auch wenn die Datenbankabfrage erfolglos war.

PHP ist nicht C. In PHP ist der Rückgabewert einer Zuweisung der
zugewiesene Wert. Aus

http://www.php.net/manual/en/language.expressions.php

zitiert:

|So far, users of PHP/FI 2 shouldn't feel any change. However, PHP
|takes expressions much further, in the same way many other
|languages do. PHP is an expression-oriented language, in the sense
|that almost everything is an expression. Consider the example we've
|already dealt with, '$a = 5'. It's easy to see that there are two
|values involved here, the value of the integer constant '5', and
|the value of $a which is being updated to 5 as well. But the truth
|is that there's one additional value involved here, and that's the
|value of the assignment itself. The assignment itself evaluates
|to the assigned value, in this case 5. In practice, it means
|that '$a = 5', regardless of what it does, is an expression with
|the value 5. Thus, writing something like '$b = ($a = 5)' is like
|writing '$a = 5; $b = 5;' (a semicolon marks the end of a
|statement). Since assignments are parsed in a right to left order,
|you can also write '$b = $a = 5'.

Bestätigt durch:

http://forum.de.selfhtml.org/test.php
   http://forum.de.selfhtml.org/test.phps

Grüße,
 CK

--
<zentrum> wie war noch mal die option in make.conf fuer das benutzen von pipes um das compile zu beschluenigen?
<CK1> CFLAGS="-pipe"
<torsten> Oder man frage einen Gentooer seiner Wahl, wie man 2 km Compilerswitches fuer seine CPU hinbekommt ;)