简体   繁体   English

PHP-$ _SERVER ['QUERY_STRING']带有“&”

[英]PHP - $_SERVER['QUERY_STRING'] has “&”

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. 在我的PHP脚本中,我试图获取查询字符串($ _SERVER ['QUERY_STRING']),将其附加到另一个URL,然后进行重定向。

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. 我打印出$ _SERVER ['QUERY_STRING']并查看页面源。 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? 仅仅是我的服务器配置还是PHP的默认配置?

UPDATE: I tested it on MODX CMS using snippet. 更新:我使用片段在MODX CMS上对其进行了测试。 If running on a regular PHP script, there is no such issue. 如果在常规PHP脚本上运行,则不会出现此类问题。 I guess the problem is with MODX. 我猜问题出在MODX。 Any idea? 任何想法?

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. 只是一个想法:如果您使用TinyMCE来编辑内容,则会将所有&'s更改为&'s这已经使我发疯了很多次。 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. 如果您停用资源的RTF编辑器或“快速编辑”资源,则可以在代码段调用中进行调试。

Also good practice: put snippet calls into a chunk . 也是一个好习惯:将代码片段调用放入块中 You can call that chunk without risking the syntax of the snippet call. 您可以调用该块,而不必担心代码片段调用的语法。

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

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