Techairlines Posted October 2, 2010 Share Posted October 2, 2010 Hello. I'm relatively new to PHP and can't figure out what's wrong. function tweet_button () { echo '<div class="twitter-share vcount"> <a class="twitter-button" rel="external nofollow" title="Share this article on Twitter" href="http://twitter.com/share?text=<?php echo $shareTitle; ?>+-&url=<?php echo $shareUrl; ?>&via=<?php if (!$retweetNick == '') { echo $retweetNick; } ?>&related=<?php if (!$retweetrelate == ''){ echo $retweetrelate; } ?>:<?php if (!$retweetrelate == '') { echo $retweetrelatedesc; } ?>" target="_blank">Tweet this article</a> <span class="twitter-count"><?php echo $retweetInfo; ?></span></div>'; } This was part of the code of a WordPress plugin I'm trying to make and when I try to activate the plugin, it gives me Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\wordpress\wp-content\plugins\sample-plugin\sample-plugin.php on line 51 Line 51 is the line that starts with &related= Thank you. Link to comment https://forums.phpfreaks.com/topic/214967-unexpected-t_constant_encapsed_string/ Share on other sites More sharing options...
phpfan101 Posted October 2, 2010 Share Posted October 2, 2010 (!$retweetNick == '') { echo $retweetNick; } ?> The above conditional isn't ended. Try: (!$retweetNick == '') { echo $retweetNick; } ?> Link to comment https://forums.phpfreaks.com/topic/214967-unexpected-t_constant_encapsed_string/#findComment-1118241 Share on other sites More sharing options...
kenrbnsn Posted October 2, 2010 Share Posted October 2, 2010 You are echoing a long string which is delimited by single quotes, but in the middle of the string you have more single quotes -- which is illegal unless you quote them, plus you have PHP tags inside the string (I'm not sure that you want that). To fix, replace the strings like (!$retweetNick == '') with (!$retweetNick == "") Ken Link to comment https://forums.phpfreaks.com/topic/214967-unexpected-t_constant_encapsed_string/#findComment-1118243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.