- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试稍微调整一下 wordpress,但我的 php 级别为 0,所以我有点烂 :/
我想添加一个自定义的“发推文”按钮(我知道已经有无数这样的按钮了,我只是想自己做,为了好玩)
所以,我正在尝试这个:
<a href="http://twitter.com/home?status=<?php strip_tags(the_excerpt()) ?>" >tweet this</a>
the_excerpt() 返回 "<p> ... excerpt ... </p>"
并且 strip_tags 函数不会剥离那些 <p>
标签!
我做错了什么?
谢谢,抱歉,如果很明显。
最佳答案
您的问题是the_excerpt()
没有将其内容返回给strip_tags()
,而是使用echo
直接输出。所以 strip_tags()
(它需要前面的 echo
来做任何工作)不能做任何事情。
使用get_the_excerpt()相反(为清楚起见插入换行符,使用时删除):
<a href="http://twitter.com/home?status=
<?php echo strip_tags(get_the_excerpt()); ?>" >tweet this</a>
顺便说一下,我还要urlencode()
摘录,否则如果它包含"
双引号或其他有趣的字符,你一定会遇到麻烦。
关于php 的 strip_tags() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2541694/
PHP手册说 5.3.4 strip_tags() no longer strips self-closing XHTML tags unless the self-closing XHTML tag
我想从一个字符串中去除所有的 html 标签,除了 ( and )。 我使用了 strip_tags();但它剥离了所有的 html 标签。 问候 最佳答案 那些需要在第二个参数中指定。 echo
我想解析这个: Text1 Text2 Text3 Text4 Text5 进入这个数组: [ "Text1", "Text2 Text3", "Text4", "Te
我在函数中编写了以下查询: $dsearch=mysql_real_escape_string($condition['title']); "select id, title , category
是否存在已知的 XSS 或其他攻击可以使其通过 $content = "some HTML code"; $content = strip_tags($content); echo $content;
我想像这样过滤掉 html 字符 $user = $_POST["user"]; //Get username from mysql_real_escape_string($user); //Aga
我最近发现了 strip_tags()以字符串和可接受的 html 标记列表作为参数的函数。 假设我想摆脱字符串中的图像,这是一个例子: $html = ''; $html = 'This shoul
我不在一台安装了 PHP 的计算机旁,想知道 strip_tags() 的结果会出现在以下文本中:“ipt>警报(‘哦哦’)ipt>” 它会返回:“alert('oh oh')”(即不承认通过删除明显
我在用户输入上使用 strip 标签来删除所有可能的标签,但 strip_tags php 函数也会删除“.. @编辑:例如: .text >. asd asd bolded alert('this
基于 strip_tags 文档,第二个参数采用允许的标签。但是,就我而言,我想反其道而行之。假设我将接受标签 script_tags通常(默认)接受,但只去除 标签。有什么可能的方法吗? 我并不是说
您知道如何使用 php 将 html 标签替换为空格字符吗? 如果我显示 strip_tags('Foobar'); 我得到的结果是“foobar”,但我需要将单词分开的是“foo bar”。 最佳答
是否存在已知的 XSS 或其他攻击使其无法通过 $content = "some HTML code"; $content = strip_tags($content); echo $content;
是否存在已知的 XSS 或其他攻击使其无法通过 $content = "some HTML code"; $content = strip_tags($content); echo $content;
详解PHP函数 strip_tags 处理字符串缺陷bug PHP 函数 strip_tags() 是一个常用函数,该函数可以剥去字符串中的 HTML、XML 以及 PHP 的标签。极大方便了对字
PHP的htmlspecialchars、strip_tags、addslashes是网页程序开发中常见的函数,今天就来详细讲述这些函数的用法: 1.函数strip_tags:去掉 HTML 及
我正在尝试稍微调整一下 wordpress,但我的 php 级别为 0,所以我有点烂 :/ 我想添加一个自定义的“发推文”按钮(我知道已经有无数这样的按钮了,我只是想自己做,为了好玩) 所以,我正在尝
我想从此字符串中删除除金额以外的所有内容: ₪700.00 我尝试过: strip_tags( $total_price_paid ); - 不够。 strip_tags( html_en
我和这个情况一样this guy . 基本上strip_tags删除标签,包括损坏的标签(documentation 中使用的术语)。是否有另一种不涉及删除 "); echo $body; 但是上面的
我和这个情况一样this guy . 基本上strip_tags删除标签,包括损坏的标签(documentation 中使用的术语)。是否有另一种不涉及删除 "); echo $body; 但是上面的
我的 php db.php 中有这个 $mysqli = new mysqli($hostname, $user, $pass, $bd); foreach($_POST as $key => $va
我是一名优秀的程序员,十分优秀!