tags:

views:

214

answers:

4

Probably really easy for a pro, but could someone re-write this from it's PHP shorthand form to non-shorthand?

($facebook) ? $fb_active_session = $facebook->fbc_is_session_active() : $fb_active_session = false;

Thanks!

+7  A: 
if($facebook) {
  $fb_active_session = $facebook->fbc_is_session_active(); 
} else {
  $fb_active_session = false;
}
karim79
@Jonathan Sampson, what with the edit?
KM
Here's proof that not everyone finds the ternary operator easy to read.
karim79
I thought 4 characters was the standard.
Sam152
+4  A: 
$fb_active_session = false;
if($facebook)
{
    $fb_active_session = $facebook->fbc_is_session_active();
}
joebert
+6  A: 

It would have been better and more clearly written (still using the ternary op) as:

$fb_active_session = ($facebook) ? $facebook->fbc_is_session_active() : false;
Jeff Ober
A: 

Think of it like this:

IS $facebook TRUE ? THEN DO THIS : IF NOT, THIS ;

redwall_hp