Jump to content

Syntax errors


Xtremer360

Recommended Posts

OMFG is it that hard to count the parenthesise

 

$image_properties = array(
                       'src' => [Open Bracket 1 ->](!empty [Open Bracket 2 ->]($this->session->userdata [Open Bracket 3 ->]('avatar')[<- Close bracket 3 )[<- Close Bracket 2 )[<- Err, oh shit, theres the bracket that shouldn't be closed]   
                        ? 'assets/peach/img/sprites/userinfo/'.$this->session->userdata('avatar') 
                        : 'assets/peach/img/sprites/userinfo/avatars/avatar.png') [<- AND OMG, who knew this is where it would close....]
                        'height' => '80px',
                        'width' => '80px',
                        'alt' => 'Avatar' 
                    );  

 

And in-case you don't know what an in-line if statement is

 

$variable = argument ? true : false;
// Example
$switchOn = true;
$isSwitchOn = $switchOn == true ? 'Yes' : 'No';

 

Completed code

$image_properties = array(
                       'src' => (!empty ($this->session->userdata('avatar') )  // OMG I REMOVED A BRACKET     
                        ? 'assets/peach/img/sprites/userinfo/'.$this->session->userdata('avatar') 
                        : 'assets/peach/img/sprites/userinfo/avatars/avatar.png')  
                        'height' => '80px',
                        'width' => '80px',
                        'alt' => 'Avatar' 
                    );  

 

Apologise for the sarcasm and the original mistake, this discussion wouldn't have taken place if I hadn't made the mistake. My bad...

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.