可以在查询字符串值中使用连字符吗? [英] Can hyphens be used in query string values?

查看:59
本文介绍了可以在查询字符串值中使用连字符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与这个问题有关.除了我的问题更为具体之外,因为它是关于查询字符串参数值中是否可以使用连字符.

My question is related to this one. except that my question is more sepcific as it is about whether a hyphen can be used in a query string parameter value.

我正在用PHP解析 $ _ SERVER ['QUERY_STRING'] .我想知道在查询字符串值中使用连字符在语法上是否正确(例如在以下情况下),或者是否必须在浏览器URL中转义连字符.下划线呢?

I am parsing $_SERVER['QUERY_STRING'] with PHP. I would like to know whether it is syntactically correct to use hyphens in query string values such as in the following case, or whether hyphens must be escaped in the browser URL. What about underscores?

http://example.com/?q1=query-string-value-one&q2=query-string-value-two

此文档的连字符应在所有符合标准的浏览器中都可以,但我想仔细检查.

According to this document hyphens should be OK in all standards-compliant browsers, but I wanted to double check.

谢谢.

推荐答案

您正在谈论必须使用

You are talking about query string parameters which must be encoded using urlencode function:

当编码要在字符串中使用的字符串时,此功能很方便查询URL的一部分,作为将变量传递到下一个的便捷方法页面.

This function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page.

根据文档-不需要编码.

这篇关于可以在查询字符串值中使用连字符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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