[英]php string convert to html
我有一个字符串<div id="myid">
... </div>
我如何将其更改为<div id="myid">
... </div>
我尝试过一些东西,但没有任何帮助吗?
更新
function get_page(){
$file = 'file.php';
$str = file_get_contents($file);
$str = html_entity_decode($str);
return $str;
}
$output = get_page();
echo $output;//don't work
固定
function get_page(){
$file = 'file.php';
$str = file_get_contents($file);
return $str;
}
$output = get_page();
echo html_entity_decode($output);//works
其功能是htmlspecialchars_decode()
。
请注意,对于解码引号的函数,您需要指定$quote_style
参数。
html_entity_decode
是你需要的: http : html_entity_decode
用这个更好......
<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// Allow <p> and <a>
echo strip_tags($text, '<p><a>');
?>
htmlspecialchars_decode($string)
$from = array('<', '>');
$to = array('<', '>');
$string = str_replace($from, $to, $string);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.