06-22-2008, 11:23 AM
|
#90 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
|
Regarding ternary operators I usually use this methodology:
If an if statement has only one simple function use a ternary operator. For others use a full if. For example:
PHP Code:
// Use ternary if(defined('CONST')) $x = (defined('CONST')) ? true : false; (!defined('CONST')) ? exit : null;
// Use full if if(defined('CONST') && isset($_SERVER['HTTP_REFERRER'])) if(strlen(strtoupper($_SERVER['HTTP_REFERRER'])) < 1)
// Improper ternary style (imo) defined('CONST') ? null: null; // Correct (defined('CONST')) ? null: null;
|
|
|
|