你如何使用PHP获取网址中的变量? [英] How do you just get the vars in a url using php?
本文介绍了你如何使用PHP获取网址中的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个url,
example.com /?/ page1
我想知道网址的GET部分是什么,例如:
?/ page1
我该怎么做?而不必拆分字符串和东西?
解决方案
以下变量将包含整个查询字符串(也就是说,
$ _ SERVER ['QUERY_STRING']
$ c如果您对$ _SERVER数组的其余内容感到好奇,它们会在PHP手册中列出 here 。
I have a url,
example.com/?/page1
and i want to find out what the GET part of the url is, for example:
?/page1
how do i do this? like, without having to split strings and stuff?
解决方案 The following variable will contain the entirety of the query string (that is, the portion of the url following the ? character):
$_SERVER['QUERY_STRING']
If you're curious about the rest of the contents of the $_SERVER array, they're listed in the PHP manual here.
这篇关于你如何使用PHP获取网址中的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文