php';s strip_tags()赢得';行不通

php';s strip_tags()赢得';行不通,php,wordpress,Php,Wordpress,我正试图对wordpress稍作调整,但我的php级别为0,所以我有点差劲:/ 我想添加一个自定义的“tweet this”按钮(我知道已经有无数个了,我只是想自己做,为了好玩) 所以,我试着这样做: <a href="http://twitter.com/home?status=<?php strip_tags(the_excerpt()) ?>" >tweet this</a> _extract()返回“…extract…”,strip_tags函数

我正试图对wordpress稍作调整,但我的php级别为0,所以我有点差劲:/

我想添加一个自定义的“tweet this”按钮(我知道已经有无数个了,我只是想自己做,为了好玩)

所以,我试着这样做:

<a href="http://twitter.com/home?status=<?php strip_tags(the_excerpt()) ?>" >tweet this</a>

_extract()返回
“…extract…

,strip_tags函数不会剥离那些
标记

我做错了什么


谢谢,如果这是显而易见的,我很抱歉。

您的问题是,
摘录()
不会将其内容返回到
条带标签()
,而是使用
回送直接输出。因此,
strip_tags()
(需要前面的
echo
来完成任何工作)什么都做不了

改用(为清晰起见插入断线,使用时删除):



顺便说一句,我也希望
urlencode()
这段摘录,如果它包含
双引号或其他有趣的字符,你肯定会遇到麻烦。

根据常识,这看起来不对:
,然后WP文档解释说,它是回显而不是返回它。 好的,使用
ob\u start
来解决问题

ob_start("callback");
the_excerpt();
$excerpt = ob_get_contents();

?>
<a href="http://twitter.com/home?status=<?php echo strip_tags($excerpt) ?>" >tweet this</a>
<?php
ob_启动(“回调”);
_摘录();
$extracpt=ob_get_contents();
?>

啊,是的,这个问题还没有马上弄清楚。但是,考虑到Wordpress的全局作用域和函数命名方案这一噩梦,回想起来就很明显了。:D+1
ob_start("callback");
the_excerpt();
$excerpt = ob_get_contents();

?>
<a href="http://twitter.com/home?status=<?php echo strip_tags($excerpt) ?>" >tweet this</a>
<?php