Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:?及;在URL中-什么';有什么区别?_Php_Url - Fatal编程技术网

PHP:?及;在URL中-什么';有什么区别?

PHP:?及;在URL中-什么';有什么区别?,php,url,Php,Url,两者的区别是什么?和&url e、 g.http://www.site.com/index.php?someVar=value&otherVar=value该?标记查询字符串的开头,&用于分隔查询字符串中的各个变量 例如,我将修改您的示例,使其更加清晰: http://www.site.com/index.php?someVar=firstVal&otherVar=secondVal URL的“位置”部分是所有内容,但不包括?,因此它只是: http://www.site.com/in

两者的区别是什么?和&url


e、 g.
http://www.site.com/index.php?someVar=value&otherVar=value

标记查询字符串的开头,
&
用于分隔查询字符串中的各个变量

例如,我将修改您的示例,使其更加清晰:

http://www.site.com/index.php?someVar=firstVal&otherVar=secondVal
URL的“位置”部分是所有内容,但不包括
,因此它只是:

http://www.site.com/index.php
这是web服务器用来查找要执行的脚本的内容。然后它将分离查询字符串(在
之后的所有内容),并将其传递给脚本(或者更准确地说,传递给PHP)。查询字符串将是以下所有字符串:

someVar=firstVal&otherVar=secondVal
然后PHP将解析查询字符串,使用
&
作为变量之间的分隔符。因此,这个查询字符串将包括两个变量:
someVar
带值
firstVal
,和
otherVar
带值
secondVal

PHP将解析查询字符串的结果存储在
$\u GET
超级全局变量中,该变量只是一个关联数组,其中键是参数的名称,值当然是关联的值

因此,在PHP中,如果在本例中执行
var\u dump($\u GET)
,它将如下所示:

array(2) {
  ["someVar"]=>
  string(5) "firstVal"
  ["otherVar"]=>
  string(5) "secondVal"
}
的意思是“参数来了”,所以它是第一个

&
意思是“这里有另一个参数”,所以它是用于连续值的

我喜欢这样,说得很好。非常感谢您的详细解释:)