note 124845 rejected from language.operators.logical by cmb

From: Date: Mon, 23 Mar 2020 22:19:58 +0000
Subject: note 124845 rejected from language.operators.logical by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214366@lists.php.net to get a copy of this message
Note Submitter: abelqsp at gmail dot com ---- Another easy way to use the 'or ( || )' operator is: <?php $type=$_POST_["type"]; //Instead of using the example code: if ($type === "1" || $type === "2" || $type === "3"){ echo "statement - executes some code if 'type' is 1 or 2 or 3"; } //We can use: The same, but with less code. if ($type === "1" || "2" || "3") { echo "statement - executes some code if 'type' is 1 or 2 or 3"; } ?> This syntax is very useful when we expect to evaluate few values. Greetings =)

« previous php.notes (#214366) next »