在PHP中获取完整的URL,没有空格 [英] getting full URL in php without white spaces

查看:74
本文介绍了在PHP中获取完整的URL,没有空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用移动浏览器将我网站的完整URL共享给whatsapp, 我尝试使用此方法来检索完整的URL,当我回显该变量时,它可以完美地工作,但是当我使用移动浏览器进行共享时,它为我提供了带有空格的链接,如下所示: 127.0.0.1/?id="rel =" nofollow noreferrer> http://127.0.0.1/?id= 40
无法打开的文件,如何在没有空格的情况下获得完整的回显链接?

I am trying to share the full URL from my website to whatsapp using mobile browser, I tried this to retrieve the full URL and it works perfectly when I echo the variable, but when I share using the mobile browser, it gives me the link with white space like this: http://127.0.0.1/?id= 40
which can not be opened, how can I get the full echoed link without no spaces?

   <?php
    $alink= (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?

            "https" : "http") . "://" . $_SERVER['HTTP_HOST'] .

        $_SERVER['REQUEST_URI'];
    ?>
    

//To Share
    <a href="whatsapp://send?text=<?php echo $message['title'] ?> <?php echo "\r\n" ?> <?php echo $alink ?> <?php echo "\r\n" ?> <?php echo $myText ?>"
                           data-action="share/whatsapp/share">Share To Whatsapp</a>

推荐答案

$ alink = str_replace('','',$ alink)

$alink = str_replace(' ', '', $alink)

手册

这篇关于在PHP中获取完整的URL,没有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆