note 92354 deleted from language.operators.comparison by thiago
| From: | thiago@php.net | Date: | Tue, 21 Jul 2009 12:03:26 +0000 |
| Subject: | note 92354 deleted from language.operators.comparison by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158532@lists.php.net to get a copy of this message | ||
Note Submitter: Enisseo
----
The PHP 5.3 "ternary" operator syntax (expr1?:expr3) is particularly useful when used for
setting a variable to a user value if set, or a default value otherwise.
For example:
<?php
$httpServerPort = getConfigVar('server.port')?:80;
$httpServerName = getConfigVar('server.name')?:'localhost';
$mailTitle = $_POST['title']?:'(no title)';
?>