unemployment Posted December 16, 2011 Share Posted December 16, 2011 How do I echo out the variable? <?php echo ((count($reminders)) > 0) ? '<span id="reminder_counter" class="menu_number f_right mrm"> {count($reminders)}</span>' : ''; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253315-syntax-error/ Share on other sites More sharing options...
Pikachu2000 Posted December 16, 2011 Share Posted December 16, 2011 Variables are not interpolated within single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/253315-syntax-error/#findComment-1298581 Share on other sites More sharing options...
unemployment Posted December 16, 2011 Author Share Posted December 16, 2011 I tried double quotes, but I'm still missing something <?php echo ((count($reminders)) > 0) ? "<span id=\"reminder_counter\" class=\"menu_number f_right mrm\"> {count($reminders)}</span>" : ""; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253315-syntax-error/#findComment-1298598 Share on other sites More sharing options...
Pikachu2000 Posted December 16, 2011 Share Posted December 16, 2011 You're trying to echo the output of a function, but the function is within the quotes. Either assign the function's output to a variable before the echo and echo that variable, or concatenate the function into the string. Quote Link to comment https://forums.phpfreaks.com/topic/253315-syntax-error/#findComment-1298600 Share on other sites More sharing options...
Drongo_III Posted December 16, 2011 Share Posted December 16, 2011 Try add the following before you echo: $reminders= count($reminders); I tried double quotes, but I'm still missing something <?php echo ((count($reminders)) > 0) ? "<span id=\"reminder_counter\" class=\"menu_number f_right mrm\"> {count($reminders)}</span>" : ""; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253315-syntax-error/#findComment-1298605 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.