2013-07-17 168 views
0

我正尝试使用以下代码在WordPress网站中拥有电子邮件分享按钮。但在single.php中添加此代码显示“解析错误:语法错误,意外的T_STRING,期待','或';'在第72行..........“中。 请帮助我解决此问题的人。解析错误:语法错误,意外的T_STRING,期待','或';'

<?php echo "<a href="mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20<?php bloginfo('name'); ?>&body=<?php the_title('','',true); ?>%20%20%3A%20%20<?php echo get_the_excerpt(); ?>%20%20%2D%20%20%28%20<?php the_permalink(); ?>%20%29" title="Email to a friend/colleague" target="_blank">Share via Email</a>"; ?> 
+0

请重新写这个剧本的很不好! – 2013-07-17 10:03:39

+0

这个问题似乎是题外话题,因为它是关于调试代码,可以很容易地通过使用体面的IDE解决。 – HamZa

+0

那么你的两个评论都是无用的,他显然不能重写脚本,否则他不会寻求帮助,如果他使用的是类似Sublime Text 2或类似的东西,那么他将无法访问调试选项(默认)。如果您要发表评论,请确保它有帮助。 – DarkMantis

回答

2

你需要逃避你的报价或改变内双引号单引号

[编辑]

事情是这样的:

<?php 
echo '<a href="mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20'. bloginfo('name') .'&body='.the_title('','',true).'%20%20%3A%20%20'. get_the_excerpt() .'%20%20%2D%20%20%28%20'. the_permalink() .'%20%29" title="Email to a friend/colleague" target="_blank">Share via Email</a>'; 
?> 
+0

我没有足够的PHP知识,因此无法编辑。能否请你帮忙? – Jogodosshu

+0

好吧更新了我的答案:) – DarkMantis

+0

非常感谢。还有一个问题出现了。代码的输出是“TestThis是Posthttp:// localhost/wordpress /?p = 1Share通过电子邮件的标题”,我认为它应该是“通过电子邮件共享”。再次感谢你的帮助。 – Jogodosshu

2

让您远离报价:

<?php echo "<a href=\"mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20<?php bloginfo('name'); ?>&body=<?php the_title('','',true); ?>%20%20%3A%20%20<?php echo get_the_excerpt(); ?>%20%20%2D%20%20%28%20<?php the_permalink(); ?>%20%29\" title=\"Email to a friend/colleague\" target="_blank\">Share via Email</a>"; ?> 

提示:使用支持语法高亮显示的优秀文本编辑器。这会为你节省很多时间。

+0

或者使用单引号符号''...''。 – Eugene

+0

@Eugene:除了链接中包含12个单引号。 – 2013-07-17 10:10:35

+0

嗨阿马尔,谢谢。代码没有解决这个问题。 @Eugene试过但没有奏效。感谢您的答复。 – Jogodosshu

1

尝试

<?php echo "<a href='mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20<?php bloginfo('name'); ?>&body=<?php the_title('','',true); ?>%20%20%3A%20%20<?php echo get_the_excerpt(); ?>%20%20%2D%20%20%28%20<?php the_permalink(); ?>%20%29' title='Email to a friend/colleague' target='_blank'>Share via Email</a>"; ?> 
+0

嗨Bindiya,谢谢。解析错误问题得到解决,但代码出现新问题。 – Jogodosshu

+0

它是什么user29378? –

+0

代码输出“&body =%20%20%3A%20%20%20%20%2D%20%20%28%20%20%29'title ='发送给朋友/同事'target =' _blank'>通过电子邮件分享“ – Jogodosshu

相关问题