note 21414 deleted from function.isset by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 28 Jun 2004 15:27:26 +0000 |
| Subject: | note 21414 deleted from function.isset by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72055@lists.php.net to get a copy of this message | ||
Note Submitter: cluebie
----
When coding with error_reporting( E_ALL ) (as all of you should strongly consider), using the
ternary operator can be useful. Normally, I avoid it but here it seems to save space and be easy to
recognize.
$var = isset($var) ? $var : "new value";
as opposed to:
if ( !isset( $var) ) {
$var = "new value";
}
This checks to see if a variable exists. If it exists, it does nothing. If it doesn't exist,
it creates it with "new value" as the initial value. This can save space when verifying
multiple variables (like from a form) while still being easily readable.