$Q = explode("/", $_SERVER["QUERY_STRING"]);
Run Code Online (Sandbox Code Playgroud)
可能$Q的价值是什么?
jog*_*_pi 12
例如,你在这样的浏览器中有一个URL
relation.php?variable1/variable2/variable3
Run Code Online (Sandbox Code Playgroud)
并且你希望得到之后的值,?
然后$_SERVER['QUERY_STRING']帮助你确定字符串之后的部分?
并根据你的问题
$Q = explode("/", $_SERVER["QUERY_STRING"]);
Run Code Online (Sandbox Code Playgroud)
变量$Q是一个值为的数组
Array
(
[0] => variable1
[1] => variable2
[2] => variable3
)
Run Code Online (Sandbox Code Playgroud)
Explode :返回一个字符串数组,每个字符串都是字符串的子字符串,通过将字符串按字符串定界符形成的边界分割而形成。
数组爆炸(字符串$delimiter,字符串$string[,int $limit])
运行此代码以了解:
/* A string that doesn't contain the delimiter will simply return a one-length array of the original string. */
$input1 = "hello";
$input2 = "hello,there";
var_dump( explode( ',', $input1 ) );
var_dump( explode( ',', $input2 ) );
Run Code Online (Sandbox Code Playgroud)
上面的例子将输出:
array(1)
(
[0] => string(5) "hello"
)
array(2)
(
[0] => string(5) "hello"
[1] => string(5) "there"
)
Run Code Online (Sandbox Code Playgroud)
并且,在您的情况下,您当前的查询字符串将被拆分为数组。并且,每个 / 将是一个数组项。
就像 ifexplode('/', 'foo/bar')
数组将包含 Foo 和 Bar 到单独的索引中。
更多信息: 爆炸 :爆炸来自 PHP.NET $_SERVER 的详细信息 :来自 PHP.NET 的 $_Server 详细信息