HDFilmMaker2112 Posted June 23, 2011 Share Posted June 23, 2011 The below is placing nothing inside the href="" area when viewed. <a href="<?php (isset($_SESSION['myusername'])) ? $page."php?investors=home" : $page.".php"; ?>">Home</a> Quote Link to comment https://forums.phpfreaks.com/topic/240192-tenary-operator-issue/ Share on other sites More sharing options...
Adam Posted June 23, 2011 Share Posted June 23, 2011 You're missing echo/print. Quote Link to comment https://forums.phpfreaks.com/topic/240192-tenary-operator-issue/#findComment-1233766 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 23, 2011 Author Share Posted June 23, 2011 <a href="<?php echo (isset($_SESSION['myusername'])) ? $page."php?investors=home" : $page.".php"; ?>">Home</a> Quote Link to comment https://forums.phpfreaks.com/topic/240192-tenary-operator-issue/#findComment-1233768 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 23, 2011 Author Share Posted June 23, 2011 For some reason the first ternary operator is evaluating to false and running true for the second one, when $_SESSION['myusername']is set. Anybody see anything in the code below or is this an issue with the sessions being set. <? echo (isset($_SESSION['myusername'])) ? '<a href="'.$page.'.php?films">Films' : (isset($_SESSION['myusername2'])) ? '<a href="'.$page.'.php?contact">Contact' : '<a href="'.$page.'.php?donate">Donate'; ?></a> Quote Link to comment https://forums.phpfreaks.com/topic/240192-tenary-operator-issue/#findComment-1233775 Share on other sites More sharing options...
Adam Posted June 23, 2011 Share Posted June 23, 2011 This unexpected behaviour is documented in the manual (example #3). Quote Link to comment https://forums.phpfreaks.com/topic/240192-tenary-operator-issue/#findComment-1233776 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.