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> 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. 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> 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> 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). Link to comment https://forums.phpfreaks.com/topic/240192-tenary-operator-issue/#findComment-1233776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.