Colton.Wagner Posted May 2, 2012 Share Posted May 2, 2012 The second $navigation variable I have set is where the issue is coming from. It seems I am not aloud to set an if statement within a variable. Can someone please show me a work around to this issue? Any help would be very much appreciated. $selected = "class=\"selected\""; $naviagtion = "<ul>"; $navigation .= "<li" . if(!isset($_GET['sub']) || ($_GET['sub'] == 1)) { return $selected; } . "><a href=\"?tier=1&sub=1\">Main</a></li>"; $naviagtion = "</ul>"; Quote Link to comment https://forums.phpfreaks.com/topic/261954-if-statement-error/ Share on other sites More sharing options...
rythemton Posted May 2, 2012 Share Posted May 2, 2012 I think you are looking for the ternary operator. A Google search found: http://www.tuxradar.com/practicalphp/3/12/4 Quote Link to comment https://forums.phpfreaks.com/topic/261954-if-statement-error/#findComment-1342347 Share on other sites More sharing options...
Colton.Wagner Posted May 2, 2012 Author Share Posted May 2, 2012 That was exactly what I needed thank you very much rep++. I posted the fix below for anyone who may be having the same issue. $navigation .= (!isset($_GET['sub']) || ($_GET['sub'] == 1)) ? "<li $selected>" : "<li>" . "<a href=\"?tier=1&sub=1\">Main</a></li>"; Quote Link to comment https://forums.phpfreaks.com/topic/261954-if-statement-error/#findComment-1342352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.