note 129721 added to language.operators.precedence
| From: | php@richardneill.org | Date: | Mon, 26 Aug 2024 11:51:40 +0000 |
| Subject: | note 129721 added to language.operators.precedence | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221496@lists.php.net to get a copy of this message | ||
The main use of "or" and "and" is that they have a lower precedence than
"=", which is useful for error-handling, with short-circuiting. So, for example:
$conn = pg_connect( ... ) or error_log ("Error, could not connect");
* If pg_connect() is successful, $conn contains the connection-object, and no error is logged.
* If pg_connect() fails, an error is logged, but $conn is FALSE, as we would wish, even though the
error_log() function is called, and returns true.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 83.151.202.231)
----
Manual Page -- https://php.net/manual/en/language.operators.precedence.php
Edit -- https://main.php.net/note/edit/129721
Del: integrated -- https://main.php.net/note/delete/129721/integrated
Del: useless -- https://main.php.net/note/delete/129721/useless
Del: bad code -- https://main.php.net/note/delete/129721/bad+code
Del: spam -- https://main.php.net/note/delete/129721/spam
Del: non-english -- https://main.php.net/note/delete/129721/non-english
Del: in docs -- https://main.php.net/note/delete/129721/in+docs
Del: other reasons-- https://main.php.net/note/delete/129721
Reject -- https://main.php.net/note/reject/129721
Search -- https://main.php.net/manage/user-notes.php