【发布时间】:2020-12-22 23:23:41
【问题描述】:
我有社交媒体按钮来分享 URL。我的代码看起来像
$socialURL = get_permalink();
//trying to add extra slash here
$socialURL = str_replace('https://', 'https:///', $socialURL);
$facebookURL = 'https://facebook.com/sharer/sharer.php?u=' . $socialURL;
我的预期网址:https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fpillartopost.online
其中 %2F 是两个斜杠
只有一个 %2F 斜杠。
由于某种原因,我的 str_replace 方法没有做任何事情。我查看了其他解决方案的 wordpress 文档,但没有任何效果,这绝对是最简单的解决方案。为什么不添加额外的斜线?
【问题讨论】: