PHP kombiniert logische Operatoren in der IF-KlauselPhp

PHP-Programmierer chatten hier
Anonymous
 PHP kombiniert logische Operatoren in der IF-Klausel

Post by Anonymous »

Wie erstelle ich erfolgreich die folgende Pseudocode-IF-Klausel in PHP?

Code: Select all

if $a is NOT equal to $b
OR
if $a is NOT both a string AND equal to $c or $d
continue
Zur Verdeutlichung der Klauseln
  • Wenn $a gleich $b ist, wird nicht fortgefahren.
  • Wenn $a NICHT gleich $b ist, wird die nächste Bedingung überprüft.


    Wenn $a gleich $c oder $d ist, aber keine Zeichenfolge ist, wird es fortgesetzt
  • Wenn $a NICHT gleich $c oder ist $d, selbst wenn es eine Zeichenfolge ist, wird es fortgesetzt
  • Wenn $a gleich $c oder $d UND eine Zeichenfolge ist, wird es NICHT fortgesetzt

Das sind meine Versuche, aber ich glaube, dass ich die zweite Klausel nicht richtig negiere

Code: Select all

if ( ($a != $b) OR !(in_array($a, array($c, $d)) AND is_string($a) ) ) {
...
}
und

Code: Select all

if ( ($a != $b) OR (!is_string($a) AND in_array($a, array($c, $d)) ) ) {
...
}
Vielen Dank

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post