这不是有史以来最好的问题,但由于搜索引擎觉得有必要忽略符号,所以我必须找个地方问。
在链接中,我有时会看到?
,例如[link]/file.extension?some_type_of_info
,甚至+、&、=等(我的意思的“最佳示例”是 youtube 视频)。这些叫什么,它们有什么作用?一个好的网站会很棒:)
我最感兴趣的是因为我有一个网站可以将内容加载到页面中,目前我允许“为页面添加书签”的方式(或者对我来说更重要的是,能够返回“页面”)是使用哈希代表我的“页面”的值。
最终我不想让页面刷新,这就是散列值很好的原因,但如果有的话我想要替代方案(不是真正的散列标记是什么意思,但大多数不同的浏览器似乎对待分配散列值在 jquery 中不同)
再次抱歉,这主要只是一个“这是什么”问题,但如果有人能告诉我使用所讨论的方法与哈希值相比的优缺点,那也很好 :)
最佳答案
参见 the url specification ,特别是 syntax components 部分:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
…和query的定义.
The query component contains non-hierarchical data that, along with
data in the path component (Section 3.3), serves to identify a
resource within the scope of the URI's scheme and naming authority
(if any). The query component is indicated by the first question
mark ("?") character and terminated by a number sign ("#") character
or by the end of the URI.
Ultimately I would like to not have the page refresh
使用the history API .这与 URL 的结构无关(除了必须是同一来源的 URL)。
关于php - 查询字符串是如何工作的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11033930/