scheda Posted August 23, 2010 Share Posted August 23, 2010 I'm getting a syntax error in this code. Basically I'm printing out a form, and depending on the value of an option, I want "checked" to be printed out. I was getting a syntax error by using the non-shorthand version of an if statement too. Any ideas why? '<input type="radio" name="position" value="1" '.(get_option("shPosition") == 1 ? echo "checked" .' /> Top <input type="radio" name="position" value="0" '.(get_option("shPosition") == 0 ? echo "checked" .' /> Bottom' Quote Link to comment https://forums.phpfreaks.com/topic/211527-syntax-error-unexpected-t_echo/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2010 Share Posted August 23, 2010 Since the content you posted is apparently being built in a string, which you are either assigning to a variable to be echoed later or directly echoing, you don't put an echo statement inside of it. You must also supply a value after the : '<input type="radio" name="position" value="1" '.(get_option("shPosition") == 1 ? "checked" : '') .' /> Top <input type="radio" name="position" value="0" '.(get_option("shPosition") == 0 ? "checked" : '').' /> Bottom' Quote Link to comment https://forums.phpfreaks.com/topic/211527-syntax-error-unexpected-t_echo/#findComment-1102804 Share on other sites More sharing options...
scheda Posted August 23, 2010 Author Share Posted August 23, 2010 Since the content you posted is apparently being built in a string, which you are either assigning to a variable to be echoed later or directly echoing, you don't put an echo statement inside of it. You must also supply a value after the : '<input type="radio" name="position" value="1" '.(get_option("shPosition") == 1 ? "checked" : '') .' /> Top <input type="radio" name="position" value="0" '.(get_option("shPosition") == 0 ? "checked" : '').' /> Bottom' Oh that works perfectly. Thank you for clarifying! Quote Link to comment https://forums.phpfreaks.com/topic/211527-syntax-error-unexpected-t_echo/#findComment-1102846 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.