0

I have the following code

<a href="<'. Url::to(['site/campaign']) .'" class="pull-right text-green"> '. HtmlPurifier::process($camp['CampaignStatus'] < 1 ? 'Intiated' : (($camp['CampaignStatus'] < 2 ? 'Drafted' )))  . '</a> 

but it's giving me the following error:

ParseError syntax error, unexpected ')'

Can anyone see what's going wrong here or how to fix it?

2
Contributors
4
Replies
25
Views
3 Weeks
Discussion Span
Last Post by hericles
1

You're missing your second option in the second ternary operator:

($camp['CampaignStatus'] < 2 ? 'Drafted' : <SHOULD BE SOMETHING HERE> )

0

Thanks for your help hericle . I just a newbie into programming world. It would really helpful if you can give me an example what you mean by <SHOULD BE SOMETHING HERE>

2

Good to hear.
For clarification for any others that find this, the initial code was an if statement without an elseif.
$camp['CampaignStatus'] < 2 ? 'Drafted'

It was incomplete as it asked

if ($camp['CampaignStatus']  < 2 ) {
        return 'Drafted';
} else if() {

}

which won't compile in any language.

Votes + Comments
Always good to see an explanation for the benefit of others. +1
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.