简体   繁体   中英

Passing escaped query string with html special chars between two pages

I'm trying to pass a query string containing special html chars (eg < ). I have to do

window.location.href = ".."

And on the other page, I have to retrieve this query string using PHP. But when I check it using isset() it returns false!

For example, when i need to escape <p> using JS like this :

function HtmlEncode(s)
      {
          var el = document.createElement("div");
          el.innerText = el.textContent = s;
          s = el.innerHTML;
          return s;
      }

window.location.href = "http://localhost/test.php?t="+HTMLEncode("<p>");

Now the url is: http://localhost/test.php?t=&lt;p&gt; .

When i do echo isset($_GET["t"]); , i get false as a result.

Or even when i try this is a <p> tag , i get $_GET["t"] equals to this is a .

Can anyone tell me what's happening ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM