note 121380 deleted from language.operators.comparison by crell
| From: | crell@php.net | Date: | Thu, 31 Mar 2022 17:42:13 +0000 |
| Subject: | note 121380 deleted from language.operators.comparison by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217872@lists.php.net to get a copy of this message | ||
Note Submitter: G
----
Do note, using the ternary operator shorthand (since 5.3), omitting the 2nd expression the first
expression will only be called once.
Before 5.3 (or not using the shorthand)
<?php
$val = f('x') ? f('x') : false;
// f('x') will be run twice
?>
After 5.3
<?php
$val = f('x') ?: false;
// f('x') will be run once
?>