0

I am trying to use following codes to have an email share button in a WordPress website. But adding this codes in single.php shows "Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in .......... in line 72". Please help me someone to fix this issue.

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

3 回答 3

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>'; 
?>
于 2013-07-17T10:03:54.260 回答
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>"; ?>

提示:使用支持语法高亮的优秀文本编辑器。这将为您节省大量时间。

于 2013-07-17T10:05:44.593 回答
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>"; ?>
于 2013-07-17T10:06:07.053 回答