0

In my php script, I'm trying to get the query string ($_SERVER['QUERY_STRING']), append it to another url, and then make a redirect.

If I use the query string without any processing, the new url shows "& amp;" for all the "&'s." Therefore the new url won't work.

I print out the $_SERVER['QUERY_STRING'] and view the page source. It does use "& amp;" for all the "&'s." It doesn't make sense to me and I wonder why. Is it just my server's configuration or PHP's default?

UPDATE: I tested it on MODX CMS using snippet. If running on a regular PHP script, there is no such issue. I guess the problem is with MODX. Any idea?

4
  • 3
    urlencode / urldecode Commented Dec 4, 2015 at 17:32
  • & amp; is html entity. Commented Dec 4, 2015 at 17:38
  • If modx is what is causing the issue, why not generate the query string yourself? Try echo http_build_query($_GET) and see if it produces the same result. Commented Dec 4, 2015 at 17:50
  • It's simple to achieve what I want, but I'm curious what could cause this. Commented Dec 4, 2015 at 18:44

1 Answer 1

0

Just an idea: If you use TinyMCE to edit stuff, it changes all &'s to &'s - that has been driving me crazy for a lot of times. That happens in snippet calls and can be debugged if you either deactivate the rich text editor for a resource or "quick edit" a resource.

Also good practice: put snippet calls into a chunk. You can call that chunk without risking the syntax of the snippet call.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.