Re: snippet
| From: | Jon Haworth | Date: | Tue, 05 Aug 2003 10:20:56 +0000 |
| Subject: | Re: snippet | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158258@lists.php.net to get a copy of this message | ||
Hi Harry,
> can someone explain this for me:
> ...
> $sFont =submit("font") ? SITE_ROOT . PROG_PATH . submit("font") :
> "";
> ...
It's called the "ternary operator", and it's a shorthand for if...else...
The line you're asking about is equivalent to:
if (submit("font")) {
$sFont = SITE_ROOT . PROG_PATH . submit("font");
} else {
$sFont = "";
}
The format is:
(condition to check) ? (result if true) : (result if false);
Cheers
Jon