分析错误:语法错误,意外的T_STRING,应为'';或者'';


Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

我正在尝试使用以下代码在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>"; ?>

您需要转义引号或将内部双引号更改为单引号

[编辑]

类似这样的东西:

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

回避您的报价:

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

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

尝试

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