douwen1937 2015-09-02 09:02
浏览 21
已采纳

可以在查询字符串值中使用连字符吗?

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.

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.

Thanks.

  • 写回答

2条回答 默认 最新

  • duanfu5239 2015-09-02 10:36
    关注

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

    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.

    According to the documentation - does not require encoding.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源