I used to do it like this:
Code: Select all
$var = 'Default Value';
if (!empty($variable)) {
$var = $variable;
}Then I found out about PHP's laziness with ORs. So now I do this:
Code: Select all
$var = 'Default Value';
empty($variable) OR
$var = $variable;Code: Select all
!(!empty($authinfo['author'][1]) OR
!trigger_error($this->base." must have a full name, please check database for errors", ERROR) ) OR
$this->fullname = $authinfo['author'][1];What's your favorite way of assigning variables while checking whether or not they exist?