解析错误:语法错误,意外T_STRING,期待','或';'

时间:2013-07-17 10:02:18

标签: php wordpress parse-error php-parse-error

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

<?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>"; ?>

3 个答案:

答案 0 :(得分: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>'; 
?>

答案 1 :(得分: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>"; ?>

提示:使用支持语法突出显示的优秀文本编辑器。那会节省你很多时间。

答案 2 :(得分: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>"; ?>