内容不正确显示
问题描述:
一个我的问题是,我的标题包含“&”,但它显示为“&”当我点击的份额。内容不正确显示
还有一个问题我是,下面的代码不承认“< BR>”或“\ n”。
我如何使它所以它会识别“&”, - 等。”以及换行符。
<?php
$gettitle = get_the_title();
$getcontent = get_the_content();
$content = substr($getcontent, 0, 20);
$content .= "<br>".$moretexthere;
$link = get_permalink();
$title=urlencode($gettitle);
$url=urlencode($link);
$summary=urlencode($content);
?>
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[summary]=<?php echo $summary;?>&p[url]=<?php echo $url; ?>','sharer','toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)">Share</a>
答
好吧,我用这个作为共享资源的URL ..
https://www.facebook.com/sharer/sharer.php?u=URLENCODEDURL
答
使用urlencode
PHP函数。
“编码的URL的 查询部分中使用的字符串时,此功能是方便...”
WordPress的例子:
<?php echo urlencode(get_the_title()); ?>