简体   繁体   English

出现放大器; 在网址中。 我该如何删除?

[英]There appears amp; in the url. How can I remove that?

http://localhost/rootfolder/contact.php?msg=empty&success=empty http://localhost/rootfolder/contact.php?msg = empty& success = empty

What is that amp;? 那是什么放大器? When I click two times on the button, that occurs. 当我在按钮上单击两次时,发生这种情况。 What do I have to do different? 我必须做些什么?

Currently, I am creating a website where you can subscribe to a newsletter and you can send a message directly on the website. 目前,我正在创建一个网站,您可以在其中订阅新闻通讯,也可以在该网站上直接发送消息。 To return to the previous page, I use a session and also the $_SERVER superglobal. 要返回上一页,我使用一个会话以及$ _SERVER超全局变量。 To keep the parameters in the url and also to change them, I wrote a function: 为了将参数保留在URL中并进行更改,我编写了一个函数:

function changeurl($page, $searched, $replacement) {
    $strfinalone = "";
    $strfinaltwo = "";
    if(!(count(explode("?", $page))<= 1)) {
      $a = explode("?", $page);
      if(strlen($a[1]) == 0) {
        $strfinaltwo = $a[0]."?".$searched."=".$replacement;
        return $strfinaltwo;
      }
      if(!(count(explode("&", $a[1])) <= 1)) {
        $b = explode("&", $a[1]);
        for ($i=0; $i < count($b) ; $i++) {
          $e = explode("=", $b[$i]);
          if(strstr($e[0], $searched) !== false) {
            if($e[1] == $replacement) {
              return $a[0]."?".$a[1];
            }
            $str = $e[0];
            $e[1] = $replacement;
            $strfinalone = join("=", $e);
            $b[$i] = $strfinalone;
            $a[1] = join("&", $b);
            $strfinaltwo = join("?", $a);
            return $strfinaltwo;
          }
        }
        $strfinaltwo = $page."&".$searched."=".$replacement;
        return $strfinaltwo;
      } else {
        $d = explode("=", $a[1]);
        if($d[0] == $searched) {
          if($d[1] == $replacement) {
            return $a[0]."?".$a[1];
          }
          $strfinaltwo = $a[0]."?".$searched."=".$replacement;
          return $strfinaltwo;
        } else {
          $strfinaltwo = $a[0]."?".$a[1]."&".$searched."=".$replacement;
          return $strfinaltwo;
        }
      }
    } else {
      $strfinaltwo = $page."?".$searched."=".$replacement;
      return $strfinaltwo;
    }
  }

 // TO GET THE URL:

$link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http").":"."//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
        $escaped_url = htmlspecialchars($link, ENT_QUOTES, 'UTF-8');

I just want to remove this amp; 我只想删除这个放大器; of the url when I click for example two times the subscribe button and there was nothing filled in. 例如,当我单击两次订阅按钮时,URL的内容并没有填写。

This is because of htmlspecialchars() which is used to some html characters. 这是因为htmlspecialchars()用于某些html字符。

And to encode url you can use urlencode() function. 要对网址进行编码,您可以使用urlencode()函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我的控制器功能加载视图时,URL中仍具有控制器名称和功能。 我该如何摆脱呢? - When my controller function loads a view, the URL has the controller name and function still in the URL. How can I get rid of this? 如何通过htaccess将我的_GET URL中的所有&#39;&%3B&#39;替换为&#39;&&#39;? - How can I replace all '&amp%3B' with '&' in my _GET url via htaccess? 从网址检索输出。 我如何使用php从URL强制下载PDF - Retrieving output from a url. How do I force the dowload of a PDF from a url using php Codeigniter Twitter库:我的回调URL是什么。 在哪里可以找到它? - Codeigniter Twitter Library : What is my Callback URL. Where can i find it? 我被要求编码一个URL。 我该怎么做呢? - I am being asked to encode a URL. How do I do this? 如何删除网址中的参数 - How can I remove parameters on my URL 从网址中删除.php扩展名。 但在最后一个值之前 - Remove .php extension from an url. But before last value Json数组包含一个图像URL。 如何显示该图像? - Json array contains an image url. How do I display that image? 布尔型PHP值在URL中传递时为空。 如何使用$ _GET []检索它? - Boolean PHP value is empty when being passed in URL. How do I retrieve it using $_GET[]? 如何重定向。 旧网址转换为新网址。 [Laravel,htacces] - how to redirect. old url to new url. [Laravel, htacces]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM