note 124845 added to language.operators.logical
| From: | abelqsp at gmail dot com | Date: | Mon, 23 Mar 2020 17:00:25 +0000 |
| Subject: | note 124845 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214364@lists.php.net to get a copy of this message | ||
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 =)
----
Server IP: 45.112.84.4
Probable Submitter: 38.142.137.34 (proxied: 148.102.115.101)
----
Manual Page -- http://php.net/manual/en/language.operators.logical.php
Edit -- https://master.php.net/note/edit/124845
Del: integrated -- https://master.php.net/note/delete/124845/integrated
Del: useless -- https://master.php.net/note/delete/124845/useless
Del: bad code -- https://master.php.net/note/delete/124845/bad+code
Del: spam -- https://master.php.net/note/delete/124845/spam
Del: non-english -- https://master.php.net/note/delete/124845/non-english
Del: in docs -- https://master.php.net/note/delete/124845/in+docs
Del: other reasons-- https://master.php.net/note/delete/124845
Reject -- https://master.php.net/note/reject/124845
Search -- https://master.php.net/manage/user-notes.php