Php 显示没有HTML标记的内容
我试图从我的数据库在我的网站上显示一些东西,但它会返回带有HTML标记的内容。在本例中,它将返回带有Php 显示没有HTML标记的内容,php,html,strip-tags,Php,Html,Strip Tags,我试图从我的数据库在我的网站上显示一些东西,但它会返回带有HTML标记的内容。在本例中,它将返回带有strong标记的文件,但它们的其他文件也带有和标记,就像下面的文件一样 T<u>his is my </u>texta<em>rea to be replaced with C</em>KEditor. 这仍然会返回相同的东西 我的代码: $fotoreactie = $app->reactiefoto($r
strong
标记的文件,但它们的其他文件也带有
和
标记,就像下面的文件一样
T<u>his is my </u>texta<em>rea to be replaced with C</em>KEditor.
这仍然会返回相同的东西
我的代码:
$fotoreactie = $app->reactiefoto($reactie['id']);
foreach ($fotoreactie as $reactiefoto) {
if(file_exists("assets/images/reactiefotos/thumbs/".$reactiefoto['foto']) && !empty($reactiefoto['foto'])){
echo '<a href="/assets/images/reactiefotos/'.$reactiefoto['foto']. '" data-fancybox><img src="/assets/images/reactiefotos/thumbs/'.$reactiefoto['foto']. '" /> </a>';
}
}
var_dump($help = $reactie['reactie']);
var_dump(strip_tags($reactie['reactie']));
echo '
<form name="formName" style="margin-top:5px;">
<input type=hidden id="'.$reactie['id'].'" name="abcName" value="'.$reactie['id'] .'"/>
<input type=hidden id="naam'.$reactie['id'].'"name="abcName" value="Reactie op bericht van '.$reactie['voornaam'].' ' .$reactie['achternaam'].'"/>
<input type=hidden id="naam2'.$reactie['id'].'"name="abcName" value="'. $help .'"/>
<a href="#reactie"><input class="btn btn-primary btn-xs" type=button value="Reageer" onclick="printIt(\''.$reactie['id'] .'\')" /></a>
</form>';
?>`
$fotoreactie=$app->reactiefoto($reactie['id']);
foreach($fotoreactie as$reactiefoto){
如果(文件_存在($reactiefoto['foto'])和($reactiefoto['foto'])为空($reactiefoto['foto']){
回声';
}
}
变量转储($help=$reactie['reactie']);
变量转储(带标签($reactie['reactie']);
回声'
';
?>`
strip_tags()
将为您执行以下操作:
$x = 'T<u>his is my </u>texta<em>rea to be <strong>replaced</strong> with C</em>KEditor.';
echo strip_tags($x);
通过将
“”
传递到您告诉它允许这些标记的strip_tags()
函数,您可以在此处自己看到这些标记的可能重复。如果不打算使用HTML标记,为什么要将它们保存到数据库中?最好在插入字符串之前对其进行适当的清理,而不是在输出上进行清理。@Matadeleo我使用的是CKEditor,它会以这种方式将其发布到数据库中。我在我的网站上的其他东西上使用这些HTML标记,你在哪里检查你的输出?它在浏览器中吗?然后可能会有html实体显示为标记。var_dump($help=$reactie['reactie'])代码>和变量转储(带标签($help))
仍将返回与我所说的相同的内容如果你看我的示例,你会发现我添加了强标记只是为了向你展示,正如你在我的问题中看到的一样,什么也不起作用,它仍然对我不起作用。那么一定有其他代码你没有告诉我们?你能把你的问题复制出来吗?那真的不可能。我在代码中使用函数和foreach
循环。问题是它是否在foreach
循环中/
var_dump($help = $reactie['reactie']);
var_dump(strip_tags($help));
$fotoreactie = $app->reactiefoto($reactie['id']);
foreach ($fotoreactie as $reactiefoto) {
if(file_exists("assets/images/reactiefotos/thumbs/".$reactiefoto['foto']) && !empty($reactiefoto['foto'])){
echo '<a href="/assets/images/reactiefotos/'.$reactiefoto['foto']. '" data-fancybox><img src="/assets/images/reactiefotos/thumbs/'.$reactiefoto['foto']. '" /> </a>';
}
}
var_dump($help = $reactie['reactie']);
var_dump(strip_tags($reactie['reactie']));
echo '
<form name="formName" style="margin-top:5px;">
<input type=hidden id="'.$reactie['id'].'" name="abcName" value="'.$reactie['id'] .'"/>
<input type=hidden id="naam'.$reactie['id'].'"name="abcName" value="Reactie op bericht van '.$reactie['voornaam'].' ' .$reactie['achternaam'].'"/>
<input type=hidden id="naam2'.$reactie['id'].'"name="abcName" value="'. $help .'"/>
<a href="#reactie"><input class="btn btn-primary btn-xs" type=button value="Reageer" onclick="printIt(\''.$reactie['id'] .'\')" /></a>
</form>';
?>`
$x = 'T<u>his is my </u>texta<em>rea to be <strong>replaced</strong> with C</em>KEditor.';
echo strip_tags($x);
This is my textarea to be replaced with CKEditor.